aboutsummaryrefslogtreecommitdiff
path: root/vis.c
AgeCommit message (Collapse)AuthorFilesLines
2016-12-17vis: always remove consumed keys from input queueMarc André Tanner1-3/+3
When given a mapping like: :map! insert >> ><>x> whose end is a prefix of another mapping we should still remove all already consumed keys from the input queue. Fixes #436
2016-12-16vis: process keys following an unmatched prefix individuallyMarc André Tanner1-1/+3
Fixes #434
2016-12-15vis: respect terminating NUL bytes in the input queueMarc André Tanner1-1/+1
It can happen that the Buffer content used for the input queue becomes <\000> where the NUL byte is intended to terminate the queue, but termkey happily parses it and because it is delimited by < and > on both sides we then interpret it as a key. In input mode this leads to the insertion of a NUL byte which is displayed as ^@. Close #432
2016-12-14vis: remove useless NULL checkMarc André Tanner1-1/+1
The very first thing we do if that check is false, is return from the function.
2016-12-09vis-lua: expose input key event in insert and replace modesMarc André Tanner1-0/+6
2016-12-08vis: rename some internal C function pointersMarc André Tanner1-8/+6
2016-11-28vis: move mark description into core codeMarc André Tanner1-0/+10
2016-11-27vis: cleanup signal handling codeMarc André Tanner1-0/+16
Move all signal handling code out of "library" code into user application.
2016-11-26vis: redirect stdout and stderr streams to /dev/null when lacking a consumerMarc André Tanner1-7/+19
If the caller of vis_pipe is not interested in the output, redirect it to /dev/null and close the pipe. Otherwise we would wait for possible output (which might never arrive) only to throw it away. As a consequence background processes can now be started with: :> { plumber <&3 3<&- & } 3<&0 2>&- whereas before one also had to explicitly close stdout: :> { plumber <&3 3<&- & } 3<&0 1>&- 2>&-
2016-11-25vis: fix I/O redirection bugs, cleanup vis_pipeMarc André Tanner1-8/+9
The `:!` command did redirect stdout to a pipe which was used by `vis-menu` to return the selected entry. However, this breaks other interactive commands such as `:!/bin/sh` where command output was never displayed. Instead we modified `vis-menu` to re-open /dev/tty for its user interface which makes it work as a regular filter `:|` This patch also obsoletes the interactive flag previously passed to the vis_pipe function. Interactive mode is instead enabled by piping an invalid range.
2016-11-22vis-lua: introduce pre-save hookMarc André Tanner1-0/+4
The first argument is the file object while the second argument denotes the full path to which it will be written. Path might be `nil` if the file is going to be written to stdout. The Lua function is expected to return a boolean value indicating whether the write operation should proceed or be aborted.
2016-11-22vis-lua: pass path as second argument to file_save_post event hookMarc André Tanner1-4/+6
The passed path can be different from file.name for instance when opening a file `a` and then doing `:w b` where file.name will be the former and path the latter.
2016-11-21vis-lua: rename file_save event to file_save_postMarc André Tanner1-3/+3
Indicating that the event is triggered *after* a successfull write.
2016-11-16vis: treat vis_keys_feed input like a macro replayMarc André Tanner1-1/+8
We need to push keys individually to the input queue such that the state machine can advance and record keys into the operator macro if necessary. Previously feeding the following input: isome text<Escape>. would not work as expected because the complete key stream was pushed to the input queue at the same time during which the operator macro was not yet active. Thus the dot command at the end would have nothing to repeat.
2016-11-15vis: defer UI initialization and overhaul argument parsingMarc André Tanner1-58/+9
Do not initalize curses UI before it is actually needed. Move vis command line argument parsing logic into main.c. This fixes `vis -v` output and exit status. Fix #351
2016-11-15vis: overhaul and unify event generation codeMarc André Tanner1-27/+78
Add another layer of indirection, move actual event generation code to a dedicated function.
2016-11-15vis: generalize special stdin handlingMarc André Tanner1-4/+12
In preparation to move argument parsing code out of vis.c.
2016-11-11vis: attempt to use the default shell of the user to execute external commandsMarc André Tanner1-2/+11
We first try $SHELL and then fall back to the shell field of the password file entry (/etc/passwd).
2016-11-10vis: make vis_draw actually draw each windowMarc André Tanner1-0/+2
2016-11-09vis: perform undo snapshotting more rarerlyMarc André Tanner1-1/+3
Do not take snapshots after every operation in insert/replace mode. As an example up until now we would take a snapshot after every <Backspace>/<Delete> press, hence when undoing changes each character would be restored individually. The same applies for <C-w> and related actions. From now on we only snaphost when: - transitioning from insert/replace mode to normal mode (but not when switching to operator pending mode) - an operation takes place from normal mode - an idle time expires in normal/replace mode
2016-11-09vis: unify VIS_OP_{INSERT,REPLACE} implementationMarc André Tanner1-4/+4
They both perform a motion before changing mode.
2016-11-08vis: fix key parsing/skipping logicMarc André Tanner1-1/+3
We should only attempt to parse special keys if they are delimited by angle brackets i.e. <Key> but not Key. Previously we would wrongly skip over the latter.
2016-10-27vis: fix :langmap behaviorMarc André Tanner1-2/+2
The mapped to latin key has typically a shorter UTF-8 representation, thus explicitly copy the NUL terminator to properly truncate the new key value.
2016-10-27vis: apply language map only to key values not modifiersMarc André Tanner1-7/+13
The language map translation should not take modifiers into account. For example if `a` is mapped to `b` then `<M-a>` should also be mapped to `<M-b>`. Fix #404
2016-10-05vis: check return value of fcntl(2) callMarc André Tanner1-3/+4
2016-09-26vis: also apply language map to operator pending modeMarc André Tanner1-1/+3
2016-09-25vis: disable language map for replacement character of `r` commandMarc André Tanner1-1/+7
The character following the `r` command in normal mode should be treated as regular input given in insert/replace mode, that is no tranformation should be applied. Temporarily disable the language map for this reason. Close #382
2016-09-19vis: set correct reference count when splitting windowsMarc André Tanner1-1/+0
The refcount is already incremented in the `window_new_file` function, no need to do it again.
2016-08-24vis: improve dot (repeat) command implmentationMarc André Tanner1-3/+5
Do not override implicit operator macro in command mode. Fix #334
2016-08-24vis: overhaul input queue handlingMarc André Tanner1-39/+27
Let vis_keys_feed always have an immediate effect. Previously, if called from a key input handler the keys would just be added to the input queue and processed once the current key handler returned. This also affects the exposed Lua API.
2016-07-06vis: fix inner text object variants when cursor is on opening delimiterMarc André Tanner1-3/+3
Except for special cases like gn and gN vis expected that a text object would be a function mapping a position to a range as follows: f: pos -> [start, end] with start <= f(pos) <= end Clearly this condition does not hold for inner text objects when the initial position i.e. the cursor is on the opening delimiter. This also obsoletes the need for the SPLIT text object flag which should be removed in a later commit if the current behavior is found to be working as expected.
2016-06-14Update the statusline when starting or ending the recording of a macroJosh Wainwright1-0/+4
2016-05-28vis: try to reduce number of redrawsMarc André Tanner1-8/+4
This is a not yet successful attempt to reduce terminal flickering when resizing windows as is for example the case when entering command mode. UI related debug output can be enabled with: $ make CFLAGS=-DDEBUG_UI=1 $ ./vis > log
2016-05-26vis: use normalized absolute file names as internal representationMarc André Tanner1-22/+70
Try to display a shorthand version in the status bar, this currently only works for files below the current working directory of the editor process.
2016-05-22Add a newline at the end of the fileSilvan Jegen1-1/+1
This is encouraged by the ISO C99 standard.
2016-05-22Remove unneeded header importSilvan Jegen1-1/+0
2016-05-22vis: refactor status line handlingMarc André Tanner1-8/+10
Make window status bar content configurable via Lua.
2016-05-22vis: add function to change window statusbar contentMarc André Tanner1-0/+4
2016-05-22vis: add functions to query window sizeMarc André Tanner1-0/+8
2016-05-22vis: consider :set horizon setting when syntax highlightingMarc André Tanner1-1/+2
2016-05-22vis: move syntax highlighting to pure Lua codeMarc André Tanner1-2/+27
2016-05-18vis: add an interactive mode to vis_pipe{,_collect}(...)Marc André Tanner1-10/+8
Previously the interactive mode was implicitly enabled by passing an invalid range. However for some use cases (e.g. completion) we need to be able to pipe a given text range to an external process without also redirecting stderr (which is used to draw the slmenu interface on top of vis).
2016-05-18vis: introduce vis_pipe_collect utility functionMarc André Tanner1-0/+19
2016-05-10Revert "vis: clean up interaction between vis and ui"Marc André Tanner1-10/+4
This caused issues on OpenBSD where it crashed the terminal. Also on Mac OS X suspend via ^Z (Ctrl-Z) was missing a \r i.e. the shell prompt was not properly redrawn. While in principle user interfaces should not have to depend on libtermkey, in practice this won't be an issue unless we are adding a non-terminal based UI (which won't happen anytime soon). This reverts commit 8f92b98848f9366e78c7aa824615bade83971513. Close #311
2016-05-10vis: improve cursor placement at EOF with enabled auto indentMarc André Tanner1-1/+1
Close #314
2016-05-08Fix autoindent when using ORichard Burke1-0/+4
2016-05-04vis: enable large file optimizations for files with long linesMarc André Tanner1-19/+0
2016-05-04vis: clean up interaction between vis and uiMarc André Tanner1-4/+10
A concrete user interface implementation should not have to depend on libtermkey. Therefore the vis core now uses an independent instance to parse keys.
2016-05-04vis: make j and k a linewise inclusive motionMarc André Tanner1-1/+2
They behave like an inclusive motion, but only if they are also linewise (which they are by default). This should make `yjp` and `ykp` yank both the current and the next/previous line when the cursor is at the start of a line. See also 532f52e9e52b98dc5749396f7353295418e0227a and #237
2016-05-01vis: delay start event until we are fully initializedMarc André Tanner1-7/+5