aboutsummaryrefslogtreecommitdiff
path: root/view.c
AgeCommit message (Collapse)AuthorFilesLines
2025-02-22style_set: add option to keep non-default style valuesinfastin1-3/+3
2025-01-08ui: pass window id when setting styleRandy Palamar1-2/+2
There are a couple times when we want to set a style without an active window. In those cases we just want to use base UI_STYLE_*s and (Win *) is not needed. This fixes a crash when trying to do a vis:info() from lua during an initial file open event. Note that this code is due for a serious refactor, ui styles should be stored in Ui and window specific styles should be stored in Win. Then we won't need any of this difficult to follow indexing into the styles array based on window id and we will never have to realloc when a new window opens. Just another thing to add to my list.
2024-05-24combine Win and UiWinRandy Palamar1-15/+19
These are not seperate things and keeping them this way makes gives this convoluted mess where both Wins and UiWins must have linked lists to the other Wins and UiWins in the program despite the fact that neither of them can exist in isolation. This, like my previous cleanup commits, is part of a larger goal of properly isolating the various subsystems in vis. Doing so is required if we ever want to be able to have a vis-server and a vis-client.
2024-05-24remove SyntaxSymbol redirection typeRandy Palamar1-21/+17
There is no reason why this isn't just a char *.
2024-05-23drop cell_blank from ViewRandy Palamar1-13/+7
No need for this to be stored in every View since its just a never modified cell with a space. Also delete the cell_unused global since all it does is provide a 0 initialized Cell.
2024-05-21remove some view pointer chasingRandy Palamar1-12/+7
Same as previous commit each window only has a single View. No need for it to be stored elsewhere in memory.
2024-05-21replace UiTermWin with UiWin & remove function pointersRandy Palamar1-14/+6
2024-05-21make Selection unopaqueRandy Palamar1-54/+15
2024-05-21make View unopaqueRandy Palamar1-110/+2
2024-05-21cleanup some single line get/set functionsRandy Palamar1-2/+2
2024-05-21cleanup vis event interfaceRandy Palamar1-3/+100
This removes the function pointer interface which was adding needless complexity and making it difficult to add new events. Now if new events are only meant for lua they only need to be added to the lua interface. This will also have a minor reduction in runtime memory usage and produce a smaller binary. The only runtime difference is that QUIT happens after all windows have been closed and their files freed.
2024-03-25ui: refactor style handlingRandy Palamar1-4/+3
The old style handling had a lot edge cases where one of the colours or the attribute wouldn't get applied correctly. This commit adds a new style_set() method to the Ui which should be called instead of manually touching a cell's style. This also means that the Cell struct can be made opaque since all the handling is now done inside the ui-terminal files. With this it is now viable to combine the light and dark 16 colour themes into a single base-16 theme. This theme works very well with the Linux virtual console and will now be the default theme regardless of if the terminal supports 256 colours or not. This should address the common complaints about vis not respecting the users default terminal colours. fixes #1151: Theming is sometimes partially applied or ignored see #1103: terminal no longer has transparency/opacity see #1040: Transparent background and setting options by default
2023-10-15view: skip empty cells before applying a styleFlorian Fischer1-0/+4
The view_style function is used to apply styles to ranges of text in a view. It approaches the starting position where the style should be applied by iterating the columns in the appropriate line using this while loop: while (pos < start && col < width) pos += line->cells[col++].len; The while loop will stop at the last character before the range where the style should be applied. This works fine until we encounter "empty" cells between the last cell containing an actual character and the first cell to be styled. This can happen if the last character before the range to style is '\t' which gets expanded with empty cells by vis according to the tabwidth option. Those empty cells get erroneously styled as well. This is fixed by skipping all empty cells encountered before the range to style. fixes #1147: `win:style` styles more terminal cells than expected
2023-10-10revert c22b2c2 & 364d212Randy Palamar1-2/+1
aka: "check for EOF before unsetting row, col & line cache in view_coord_get" "fix bug where visual-line selections after view were considered visible" These commits have created more bugs then they fix. Reverting them reintroduces #1074: Slave selection strangled by view cliff. Fixes #1143: Disappearing selection
2023-08-27Make tabwidth option window-localAlexey Yerin1-0/+6
2023-08-24Lua API: access and set all available optionsRandy Palamar1-0/+8
The first point of this commit is to allow all options to be read from lua. This has a number of uses for plugin writers. They are grouped into a couple of tables depending on what they control: `vis.options`: table with global configuration `win.options`: table with window specific configuration The second point is to allow you to set all these options as if they were simply lua variables. Technically this is already possible by using `vis:command("set ...")` but personally I think this interface is cleaner. Note that this already possible for some things like the current mode (eg. vis.mode = vis.modes.VISUAL). Examples: `vis.options.ai = true` `win.options.brk = " !?."` `win.options = { showeof = true, showtabs = true } There are a number of related issues and pull requests: closes #803: Lua API: let plugins read the values of options closes #812: Window layout property supersedes/closes #717: Add ability to access tabwidth from Lua supersedes/closes #1066: expose UI layout and allow it to be set from lua API
2023-07-28view.c: add word wrappingAndrey Proskurin1-30/+86
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-28view: refactor view_addchAndrey Proskurin1-78/+78
2023-05-22check for EOF before unsetting row, col & line cache in view_coord_getJeremy Bobbin1-1/+2
This commit fixes c22b2c2, which introduced a bug when the EOF was in view.
2023-03-19fix bug where visual-line selections after view were considered visibleJeremy Bobbin1-1/+1
prior to this patch, if you had a visual-line selection after the view, and try to move it(& all other selections) up into the buffer, the selection would appear prematurely. https://github.com/martanne/vis/issues/1074
2022-11-29fix miscellaneous spelling mistakesNick Hanley1-2/+2
2020-12-10fix typos in commentsMoesasji1-1/+1
2020-11-20view: make view_selections_dispose_all O(n)Mateusz Okulus1-2/+5
The for loop in selection_free won't run because the next element will always be NULL, because we are freeing from the end. Close #852
2020-04-27Avoid use of VLAsMichael Forney1-2/+11
2018-05-16vis: make sure zb redraws line at the bottom if possibleMarc André Tanner1-3/+0
Previously it would do nothing if the cursor was already on the last display line. Fix #697
2018-03-12view: use strncat instead of an inline loop to concatenate cell dataMarc André Tanner1-4/+1
2018-03-12view: fix buffer overflow when dealing with combining charactersMarc André Tanner1-2/+5
The `cell.len` attribute refers to the number of bytes of the underlying text which are represented by this cell. The actual NUL terminated data being displayed can have a completely unrelated length. For example a NUL byte has a `cell.len` of 1, but is displayed as `cell.data = "^@"`. Because we currently have a fixed cell capacity of 16 bytes (including the terminating NUL byte) long sequences of combining characters won't be displayed correctly. See also #679
2018-03-11view: properly advance over incomplete unicode sequenceMarc André Tanner1-1/+1
When fetching more text we have to skip the bytes processed by the previous cell, otherwise we end up in an infinite loop.
2018-03-11Reset parsing state after mbrtowc(3) failureMarc André Tanner1-0/+1
The standard says "if an encoding error occurs ... the conversion state is unspecified".
2017-07-14vis-lua: make selection first class primitives in Lua APIMarc André Tanner1-2/+2
2017-07-08view: keep but clear primary selection if instructed to replace allMarc André Tanner1-1/+4
Previously the last selection was kept implicitly to statisfy the invariant that at least one selection needs to exist.
2017-07-05vis: make sure all selections have same anchored stateMarc André Tanner1-1/+3
With the current model the differences between normal and visual mode is that in the latter selections are anchored (meaning one endpoint remains fixed), while in normal mode both endpoints can in principle be updated simultaneously (currently they are always colapsed to a singleton selection, giving the impression of cursors).
2017-07-04vis: implement `gv` by means of new "^ registerMarc André Tanner1-20/+0
This window local register holds the last active selections.
2017-06-27vis: properly set initial window ui optionsMarc André Tanner1-1/+1
This should keep the EOF markers visible when another option is enabled. The whole UI option handling is a bit of a mess. In the longterm more of the drawing code should be moved into Lua.
2017-06-27Merge branch 'show-eof' of https://github.com/p-e-w/visMarc André Tanner1-1/+9
Conflicts: view.c view.h
2017-06-27Merge branch 'theme-tweaks-2' of https://github.com/p-e-w/visMarc André Tanner1-1/+1
Conflicts: view.c
2017-06-15view: make sure primary selection is visibleMarc André Tanner1-0/+3
2017-06-15view: add functions to save/restore arbitrary rangesMarc André Tanner1-0/+23
2017-06-15view: add functions to get/set all selectionsMarc André Tanner1-5/+34
2017-06-15view: disallow setting of invalid selectionsMarc André Tanner1-5/+9
2017-06-15view: fix view_selections_setMarc André Tanner1-8/+2
The anchor needs to be set after the cursor was positioned, otherwise the cursor placement will immediately destroy the selection for in the non-anchored case.
2017-06-15view: do not automatically anchor selections when setting rangeMarc André Tanner1-1/+0
2017-06-15view: introduce view_selections_normalizeMarc André Tanner1-0/+22
Dispose all invalid and merge all overlapping selections.
2017-06-15vis: rename uses of Cursor to SelectionMarc André Tanner1-296/+293
2017-06-15view: rename view_cursors_columnMarc André Tanner1-1/+1
2017-06-15view: rename view_cursorsMarc André Tanner1-1/+1
2017-06-15view: rename view_selection_anchoredMarc André Tanner1-1/+1
2017-06-15view: rename view_cursors_column{,count,next}Marc André Tanner1-2/+2
2017-06-15view: rename view_cursors_numberMarc André Tanner1-1/+1
2017-06-15view: rename view_cursors_countMarc André Tanner1-1/+1