aboutsummaryrefslogtreecommitdiff
path: root/sam.c
AgeCommit message (Collapse)AuthorFilesLines
2017-03-19Move :set horizon option implementaiton to luaMarc André Tanner1-6/+0
2017-03-19Move :set theme option implementation to luaMarc André Tanner1-6/+0
2017-03-19Move :set syntax option implementation to luaMarc André Tanner1-6/+0
It is no longer possible to change the used syntax by assigning to the `win.syntax = name` field, instead the function win:set_syntax(name)` should be called. The distinction between filetype and syntax lexer to use should probably be clarified/cleaned up at some point.
2017-03-19vis: add infrastructure to dynamically add :set optionsMarc André Tanner1-29/+22
2017-03-02vis: remove :bdelete commandMarc André Tanner1-4/+0
It does not really fit into the style of the rest of the command language. Eventually we should be able to express this kind of thing using a looping construct based on the `X` and `Y` commands.
2017-02-27vis: allow useage of file dialog for :read commandMarc André Tanner1-13/+0
Fix #505
2017-02-24vis: make help texts optional to produce a smaller binaryMarc André Tanner1-62/+61
$ ./configure --disable-help shrinks the binary by about 20K on a x86_64 system.
2017-02-21sam: make sure all commands can be undoneMarc André Tanner1-0/+2
Take a snapshot before and after processing the transcript.
2017-02-21sam: reformat code to avoid one level of indentationMarc André Tanner1-34/+34
2017-02-09sam: fix bogus clang compiler warningMarc André Tanner1-1/+2
Strictly speaking this is a compiler bug: https://llvm.org/bugs/show_bug.cgi?id=22062 The C11 standard section 6.4.4.3 says: "An identifier declared as an enumeration constant has type int." and 6.7.2.2: "Each enumerated type shall be compatible with char, a signed integer type, or an unsigned integer type. The choice of type is implementation-defined, but shall be capable of representing the values of all the members of the enumeration." So while `err` can store a value larger than that of any enumeration member, it could also be of signed type, resulting in a warning about comparing integers of different signs. Converting it to size_t before the range check and array indexing, should fix both warnings. Fix #478
2017-02-08sam: execute commands even if we have no valid rangeMarc André Tanner1-2/+3
In an ideal world this should never happen. However, if for some reason all cursors/selections become invalid, default to an empty range. This at least allows to terminate the editor gracefully whereas before the command would silently be ignored.
2017-02-05vis: add file argument to vis_pipeMarc André Tanner1-2/+2
2017-02-02vis: support rudimentary help search using :help patternMarc André Tanner1-1/+1
The argument needs to be a valid regular expression. It currently clobbers the last used search term and hence allows repeated searches using `n` and `N` respectively.
2017-02-02Slight code cleanups, use buffer API where appropriateMarc André Tanner1-7/+3
2017-02-01Update year number to 2017Marc André Tanner1-1/+1
2017-01-31sam: optmize transcript insertion for common caseMarc André Tanner1-2/+9
This esentially performs an insertion sort. Rather than iterating the list from the start every time keep track of the latest change and optmize for monotonically increasing file positions.
2017-01-31vis: add workaround for broken color handling in Terminal.appMarc André Tanner1-0/+7
Terminal.app sets $TERM=xterm-256color and ships a corresponding terminfo description advocating that it is capable of color changes to the 256 color palette when in fact it can not. We introduce a new boolean option "change-256colors" which is true by default but can be used to disable color changes. It is automatically set if Terminal.app is detected using $TERM_PROGRAM. This should fix display artifacts as described in #456.
2017-01-26sam: disallow destructive commands in groups and looping constructsMarc André Tanner1-8/+41
This should fix segfaults for commands like `:{ q i/foo/ }` or `:x/pattern/ q` where a command invalidates the current window. The checks are a bit too strict, for example a destructive command at the end of a non-nested group would be fine, but is currently also rejected.
2017-01-19sam: use 'm to reference mark mMarc André Tanner1-3/+3
The manual was already mentioning that. Fix #468
2017-01-14sam: do not clobber error value when failing to parse a groupMarc André Tanner1-0/+2
When encountering a parsing error within a { } command group do not set the error cause to unmatched brace.
2017-01-13sam: remove s (substitute) command use x (extract) and c (change) insteadMarc André Tanner1-8/+3
They are roughly equivalent, instead of s/pattern/replacement/ to replace the first occurrence of pattern you can specify an address to the change command: /pattern/ c/replacement/ the only difference being that the first command is restricted to the current line. -+x/pattern/ c/replacement/ also restrictes matches to the current line, but performs the substitution on the whole line not only the first match. Currently it is not possible to only replace the n-th match as `s2/pattern/replacement/` would do in sam(1). A possible alternative syntax generalizing this concepts and applying it to the `x` and `g` commands will be investigated in the future. Global substitution as in %s/pattern/replacement/g can be performed using x/pattern/ c/replacement/
2017-01-13sam: allow empty text specifiersMarc André Tanner1-2/+5
Before the i, a, c commands would fail when given an empty text //.
2017-01-13sam: allow input text to refer to search registersMarc André Tanner1-4/+54
& refers to the most recent complete match and \1 - \9 refer to the last sub-expression matches.
2017-01-13vis: introduce registers 0-9 and & to capture search matchesMarc André Tanner1-2/+11
These are currently only updated for `x` and `y` sam commands, whether they should be updated for other search related activities (`/`, `?`, `n`, `N`, `*`, `#` etc.) needs to be investigated.
2017-01-13sam: create new selections for changed rangesMarc André Tanner1-44/+68
This is akin to sam where dot is set to the result of a command.
2017-01-12sam: implement parallel grouping behaviorMarc André Tanner1-130/+142
2016-12-31vis: allow user registered :-commands to specify a help textMarc André Tanner1-4/+0
2016-12-31sam: use buffer_move where appropriateMarc André Tanner1-4/+4
2016-12-30sam: execute X and Y commands only once not for every selectionMarc André Tanner1-2/+2
2016-12-30sam: change write command implementation to not change argv[]Marc André Tanner1-6/+6
The same Command struct might be used for multiple command executions. An example is `:X wq` which is roughly equivalent to `:wqa` in vim.
2016-12-30sam: explicitly pass invalid range for X and Y commandsMarc André Tanner1-1/+1
These are never used because there is always an implicit select command prepended.
2016-12-30sam: use more expressive name for select commandMarc André Tanner1-2/+2
This is not really used, but commands can expect to have argv[0] set to something. Also "s" is ambigious with the substitute command.
2016-12-14vis: add new :set savemethod auto|atomic|inplace optionMarc André Tanner1-2/+9
Specifies how the current file should be saved, `atomic` which uses rename(2) to atomically replace the file, `inplace` which truncates the file and then rewrites it or `auto` which tries the former before falling back to the latter. The rename method fails for symlinks, hardlinks, in case of insufficient directory permissions or when either the file owner, group, POSIX ACL or SELinux labels can not be restored. The option defaults to `auto`.
2016-12-14text: expose text save method to calling codeMarc André Tanner1-1/+1
There are cases where it is useful to specify how the file should be saved.
2016-12-03vis: improve :set option number parsingMarc André Tanner1-2/+1
Only accept numbers in range [0, INT_MAX]. Reject trailing garbage, where before something like `:set cc 50NaN` worked it will now cause an error. Close #418
2016-11-28sam: introduce `m as an address refering to mark mMarc André Tanner1-0/+15
2016-11-27sam: stricter command parsingMarc André Tanner1-5/+20
Properly detect unbalanced curly braces and spurious output at the end of a group.
2016-11-25vis: fix I/O redirection bugs, cleanup vis_pipeMarc André Tanner1-4/+4
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: add `:set escdelay nn` optionMarc André Tanner1-0/+6
Make the delay used to distinguish between an <Escape> key and other terminal escape sequences such as for the Meta key run time configurable. The value is given in miliseconds and defaults to 50ms. Notice that terminal multiplexers like dvtm or tmux might also induce some delay which has to be configured independently.
2016-11-22vis: populate :set option map at startupMarc André Tanner1-0/+8
2016-11-22vis-lua: also emit save events when writing to stdoutMarc André Tanner1-0/+6
The path argument will be nil.
2016-11-22vis-lua: introduce pre-save hookMarc André Tanner1-0/+5
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-1/+1
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-1/+1
Indicating that the event is triggered *after* a successfull write.
2016-11-21sam: change default addresses used for commands in normal modeMarc André Tanner1-11/+12
Except for special commands like `w` and `wq` treat the cursor as an implicit one character selection to which the command is applied.
2016-11-19sam: change default address of "s" command to current lineMarc André Tanner1-1/+1
2016-11-16sam: use default shell command for <, >, | and ! when applicapleMarc André Tanner1-3/+9
If the shell command is omitted, the last shell command (of any type) is substituted. The most recently used shell command is stored in a new register currently named `!`.
2016-11-16sam: support an empty regex as an alias for the most recently used oneMarc André Tanner1-3/+2
As in sam if an empty regex // is provided we substitute in the most recently used one. 0/regexp/// Will match the second occurrence in the fie.
2016-11-15sam: make `:w` and `:wq` honor their given rangeMarc André Tanner1-17/+27
As in visual mode write commands have to be forced with ! if the changes are destructive i.e. only parts of the file are written.
2016-11-15sam: `e`, `q`, `X`, `Y`, `!` and all vi commands should not take addressesMarc André Tanner1-23/+23