summaryrefslogtreecommitdiffstats
path: root/gencadr.txr
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-09-05 20:23:28 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-09-05 20:23:28 -0700
commit31da8a2f9df639137bfd4232bf6fc4777f1c2c61 (patch)
tree7995a13493b9dbb6b33321688406a4a1e19ed28a /gencadr.txr
parent5fb2d4a21816d2d06ec0b12ff7be5b09a7771ce4 (diff)
downloadtxr-31da8a2f9df639137bfd4232bf6fc4777f1c2c61.tar.gz
txr-31da8a2f9df639137bfd4232bf6fc4777f1c2c61.tar.bz2
txr-31da8a2f9df639137bfd4232bf6fc4777f1c2c61.zip
linenoise: separate display semantics from buffer
The linenoise edit buffer now shows a printed representation of underlying data. In this printed representation, multiple characters can denote a single physical character, so that a control code like 15 can be displayed as ^M. In the future, this will help with a Unicode-ization of linenoise. The actual edit routines now operate on the data array rather than buf, and the new function sync_data_to_buf is used to synchronize buf with data for the sake of refreshing the display. * linenoise/linenoise.c (LINENOISE_MAX_DISP): New variable. (struct lino_state): buf member becomes an array, so the display buffer is now in the structure, and not stack allocated in the linenoise function. New members data, dlen and dpos for tracking the underlying data. Also, the buflen member variable is gone. Uses of buflen are replaced with sizeof. (sync_data_to_buf): New static function. (complete_line): Pass ls->data to callback, rather than ls->buf. In the saving and restoring trick used when displaying completions, we must copy in the completion to the data array; we cannot swizzle a buffer pointer like before. The restoration of the state is simplified; just copy back the entire original. Lastly, when a completion is selected, it must go into the data array, and not buf. Here, there is a bugfix; it appears that refresh_line was not called; I had to add that call. (Did that work before this change?) (refresh_line): Call sync_data_to_buf before calling either refresh function. (edit_insert, edit_move_left, edit_move_right, edit_move_home, edit_move_end, edit_history_next, edit_backspace, edit_delete_prev_word): Operate on data array, dlen and dpos rather than buf, len and pos. (edit): Doesn't take buffer and length parameters any more. No need to initialize context structure members buf, or removed member buflen. New members dlen and dpos have to be initialized. Inlined edit operations now work with data array, rather than buf. (go_raw): Buffer and buflen arguments are gone. Non-tty code still allocates buffer on stack, but only in its local block. (linenoise): Do not instantiate local buffer for passing to go_raw, which doesn't take one any more. When finished, duplicate the string in the data array.
Diffstat (limited to 'gencadr.txr')
0 files changed, 0 insertions, 0 deletions