aboutsummaryrefslogtreecommitdiff
path: root/sam.c
AgeCommit message (Collapse)AuthorFilesLines
2025-01-04remove duplicated read_buffer functionsRandy Palamar1-7/+4
When you take a pointer to a function in C that function is going to appear in full in the final binary. This means that there were 3 sections of the final binary with the exact same code. You could argue that in very high performance programs having that function closer to the current instruction when it is needed will give a performance boost but there are so many other places to gain more significant speed ups in vis before that would be remotely relevant. In fact, removing these allows the buffer_append call to inlined so that buffer_insert can be hopped to directly instead of including a useless hop in the middle.
2024-05-21remove some view pointer chasingRandy Palamar1-13/+12
Same as previous commit each window only has a single View. No need for it to be stored elsewhere in memory.
2024-05-21make Selection unopaqueRandy Palamar1-5/+5
2024-05-21make View unopaqueRandy Palamar1-2/+2
2024-05-08drop deprecated option namesRandy Palamar1-20/+10
2024-02-01allow disabling of statusbarsewn1-0/+6
2023-10-23sam: reject invalid ranges for cmd_extract ("x"/"y")Randy Palamar1-1/+1
fixes #1152: `:2x/foo/<cr>` in a file with only one line makes vis get stuck in an infinite loop
2023-08-27Make expandtab option window-localAlexey Yerin1-1/+1
2023-08-27Make tabwidth option window-localAlexey Yerin1-1/+1
2023-08-26support old option names but mark as deprecatedRandy Palamar1-10/+20
This is in response to a comment left on a35e7ea. Backwards compatibility is a good idea for at least a release.
2023-08-24sam.c: rename a number of options to match lua apiRandy Palamar1-5/+5
2023-07-28view.c: add word wrappingAndrey Proskurin1-0/+12
this is contolled by the wrapcolumn/wc and breakat/brk options related #142: Word wrap and line breaks related #932: Vis for Prose? related #1092: Disabling line wrapping
2023-07-18Add fullscreen param to vis_pipe_collect() and Lua API vis:pipe()Jörg Bakker1-2/+2
This enables restoring the terminal from a fullscreen command like curses based program. Use cases are e.g. a file picker based on some external program like nnn (https://github.com/jarun/nnn).
2023-06-22allow underscore (_) in command namesRandy Palamar1-1/+1
fixes #971
2023-05-28fix use after free in cmd_files()Randy Palamar1-4/+6
When the cmd closes the window the window pointer gets freed along the way. We can't use win->next to update the loop variable if sam_execute() has been called. Instead we can store win->next early and use that variable to continue the loop. fixes #1090
2021-02-11sam: simplify trailing match handling for x/y commandsMarc André Tanner1-6/+2
Should be no functional change, just a simpler implementation.
2021-02-11sam: tweak handling of zero length matches in y commandsMarc André Tanner1-4/+9
In sam(1) a command like x/[a-z]+/ y/-?/ matches every character individually, whereas in vis it would produce a zero length match before each character as is correctly the case for the x counter part.
2021-01-25sam: produce empty match at the end of looped rangeMarc André Tanner1-2/+2
In certain cases (e.g. involving negated character classes) the last empty match of an x command would wrongly be skipped. See #925
2021-01-25sam: only skip the last empty match if it follows a newlineMarc André Tanner1-1/+2
This further tweaks the hack introduced to ignore the last match of ^ at the end of the file, see 1a158268c7693b00bf43c7e81034816d8d00358c.
2020-12-10fix typos in commentsMoesasji1-2/+2
2020-11-13sam: simplify boolean expression, start < end implies end > 0Marc André Tanner1-1/+1
2020-09-19Add ignorecase optionEvan Gates1-0/+6
Add a global ignorecase boolean option. When set add REG_ICASE to cflags when calling text_regex_compile().
2020-08-29text: provide save function taking a directory descriptorMarc André Tanner1-1/+2
The standard does not specify mkstempat(3). We currently implement it in a non thread safe manner, by temporarily changing the process working directory before invoking mkstemp(3).
2020-08-01Update copyright yearMarc André Tanner1-1/+1
2020-04-27Avoid use of VLAsMichael Forney1-3/+3
2020-03-15sam: fix X and Y commands which were interchangedMarc André Tanner1-2/+2
Fix #820
2020-02-29sam: fix spurious "file exists" warningsMarc André Tanner1-1/+1
When initially opened with a non-existing file we would not correctly track the file's meta data resulting in spurious warnings upon subsequent writes. It is fixed by also saving the meta data for previously non-existing files with matching paths.
2020-02-23sam: warn when attempting to write to an existing fileMarc André Tanner1-0/+4
Add ! to override.
2020-02-23sam: fix modification time comparision when writing fileMarc André Tanner1-6/+13
The modification time should only be compared when dealing with the same file i.e. the following should work without a warning: $ touch foo; sleep 1; touch bar $ vis foo :w bar Also switch from path to inode based file equality testing.
2020-02-22sam: re-take range after pre-save hooks are runalex1-2/+14
A vis.events.FILE_SAVE_PRE callback may mutate the file text, making the original range passed to cmd_write incorrect. It is unclear how to realign the range after the callback is done for the cases where an active selection in visual mode is present or an explicit range like :1,2w! was specified. However, this commit resolves the issue for the case where the whole file is expected to be written.
2020-02-12sam: support optional count for text commandsMarc André Tanner1-12/+21
The text given for the a, i and c commands can be prefixed with an optional count indicating how often the text should be inserted, defaults to 1.
2020-02-12sam: move parse_number code, no functional changeMarc André Tanner1-9/+9
2020-01-28vis: support an optional exit status in :q and :qall commandsMarc André Tanner1-2/+2
This can for example be used to abort git commit messages with :q! 1.
2020-01-27vis: pass absolute path to pre/post save eventsMarc André Tanner1-13/+24
2020-01-24sam: fix ^ anchor behavior in looping commandsMarc André Tanner1-3/+7
Previsouly a command like: x/^.*\n/ would only select every second line. Fixes #774
2020-01-23remove redundant layout option abbreviationKarl Schultheisz1-1/+1
No need to explicitly specify "lay" as an abbreviation, since "layout" already makes it available via prefix logic.
2019-05-23Add layout optionKarl Schultheisz1-0/+6
This introduces a new `set` option for setting the layout to vertical or horizontal, which previously could not be done without creating a new window (via `split` or `vsplit`). Now, `set layout|lay h|v` will control this without creating a new window.
2018-05-30vis: add loadmethod optionMarc André Tanner1-0/+6
Valid values are `read`, `mmap` or `auto`.
2018-05-30sam: always apply | command to existing selectionsMarc André Tanner1-1/+1
2018-05-30sam: normalize selections after command executionMarc André Tanner1-0/+3
As a trivial example if multiple selections exist running a command like :, should merge them.
2018-05-30sam: change nomencalture, use selection where appropriateMarc André Tanner1-16/+16
2018-05-16sam: keep selections after :> commandMarc André Tanner1-3/+0
Fix #700
2018-04-15Update year numbers in copyright informationMarc André Tanner1-1/+1
2018-02-19sam: fix g/^$/Marc André Tanner1-2/+7
With POSIX ERE the pattern ^$ matches strings ending with a new line because an empty match is reported after the trailing newline at the very end of the input. This is undesirable for use cases like x g/^$/ d which is supposed to delete all empty lines of a file. As a fix we disregard empty matches at the end of the given range.
2017-07-14vis-lua: make selection first class primitives in Lua APIMarc André Tanner1-3/+3
2017-07-10vis: implement jump list in terms of marksMarc André Tanner1-0/+1
2017-07-07vis: use marks instead of registers to store selectionsMarc André Tanner1-5/+10
The key binding remain the same, but the selections are now stored on a per-buffer basis.
2017-06-27Merge branch 'show-eof' of https://github.com/p-e-w/visMarc André Tanner1-0/+6
Conflicts: view.c view.h
2017-06-15sam: simplify print command implementationMarc André Tanner1-16/+11
2017-06-15vis: rename uses of Cursor to SelectionMarc André Tanner1-110/+110