aboutsummaryrefslogtreecommitdiff
path: root/view.c
AgeCommit message (Collapse)AuthorFilesLines
2017-03-22view: rename view_dirty to view_invalidateMarc André Tanner1-1/+1
2017-03-19view: use correct default cell styleMarc André Tanner1-4/+3
2017-03-16view: mark view as dirty even when resizing to same sizeMarc André Tanner1-1/+3
This makes sure that a successive view_update call returns true and as a result the status bar will be correctly redrawn.
2017-03-14Restructure display codeMarc André Tanner1-106/+41
Use pull instead of push based model for display code. Previously view.c was calling into the ui frontend code, with the new scheme this switches around: the necessary data is fetched by the ui as necessary. The UI independent display code is moved out of view.c/ui-curses.c into vis.c. The cell styles are now directly embedded into the Cell struct. New UI styles are introduced for: - status bar (focused / non-focused) - info message - window separator - EOF symbol You will have to update your color themes. The terminal output code is further abstracted into a generic ui-terminal.c part which keeps track of the whole in-memory cell matrix and #includes ui-terminal-curses.c for the actual terminal output. This architecture currently assumes that there are no overlapping windows. It will also allow non-curses based terminal user interfaces.
2017-02-28view: fix display when inserting text at start of fileMarc André Tanner1-2/+9
Before cebb24b36ac45cc7c6912481cacd29ef9d5c68b9 a mark at the start of the file was treated specially to always return position zero. Since this was no longer the case the following would insert text before the visible area: <PageDown><PageUp><PageUp>ifoo
2017-02-27view: reposition cursor after restoring selectionMarc André Tanner1-0/+1
This should fix selection changes after shift operators in visual mode. The problem was that the NOP motion which is executed when switching back into visual-line mode destroys the selection if the cursor is not already placed on a selection boundary. Fix #501
2017-02-23view: make sure viewport remains valid when scrolling upMarc André Tanner1-1/+1
In a file with windows style \r\n line endings scrolling up would wrap around to the end of the file.
2017-02-12view: improve handling of long sequences of combining charactersMarc André Tanner1-1/+3
They will still not be displayed correctly, but at least they should no longer cause memory errors.
2017-02-08view: fix view_cursors_scroll_to to operate on current stateMarc André Tanner1-0/+1
This should fix display issues when entering the first newline of a file.
2017-02-04view: reduce redraws upon selection changesMarc André Tanner1-10/+10
2017-02-04view: keep track of the most recently created cursorMarc André Tanner1-4/+10
Previously this was done implicitly through the primary cursor which was always adjusted when a new cursor is being created. However, this is no longer the case and we do not want to iterate through all cursors when creating a new one. In the longterm we might want to store cursors in a contiguous memory location (i.e. an array) instead of chaising pointers all over the place.
2017-02-04view: do not let new cursors automatically become primaryMarc André Tanner1-1/+0
We currently have the invariant that the primary cursor is always placed within the visisble viewport. Previously view_cursors_new would automatically make the new cursor primary. This in turn causes the viewport to be adjusted triggering lots of unnecessary redraws. As a result commands creating many new selections might become unbearably slow. Instead the caller has to explicitly make the new cursor primary.
2017-01-31view: add back link from selection to corresponding cursorMarc André Tanner1-14/+12
Can be NULL if no cursor is associated with the given selection (this is currently never the case). Avoids a loop through all cursors when clearing selections.
2017-01-20vis: improve new line handling at end of fileMarc André Tanner1-5/+12
<Enter> at the end of the file now inserts two newlines, unless there is already one in place. This ensures that in 'normal' operation the file is always new line terminated (as mandated by POSIX). It also means that there is no problem displaying the right amount of ~ symbols at the end of the file. Unlike in vim the cell beyond the end of the file remains adressable even in normal mode. This means something like the following (starting from an empty file) might be a little confusing: o<Escape><Left>dd Because the starting position is beyond the last newline of the file, nothing will be deleted. For now we prefer to avoid the additional complexity, and difference in behavior between normal and insert mode, needed to fix this slight inconsistency. Fix #294
2017-01-16vis: cleanup regex header inclusionMarc André Tanner1-1/+0
2017-01-15view: fix check to prevent duplicate cursor creationMarc André Tanner1-1/+4
Previously repeatedly pressing <Ctrl-j> at the start of the file would keep creating cursors.
2017-01-14view: enforce invariant that cursor is within selectionMarc André Tanner1-5/+6
A cursor does not necessarily have to be at a selection boundary (e.g. in visual line mode) but it has to be within the selection.
2017-01-13view: add infrastructure for delayed cursor destructionMarc André Tanner1-2/+23
At least one cursor (referred to as primary or main cursor) has always to exist. In the sam command language implementation we might want to dispose a cursor even if it is the primary one before later commands will create different ones (e.g. `:x/pattern/ { i/>>>/ a/<<</ }`). This commit introduces view_cursors_dispose_force. If called on the last remaining cursor, its selection is cleared and it is marked for destruction as soon as a new cursor is created. view_cursor_disposed returns the cursor marked for deletion (if any) and clears the descruction flag.
2016-12-22text: remove Filepos typedefMarc André Tanner1-3/+3
The idea might be good, but it was almost unused.
2016-12-05view: make cursor placement more robustMarc André Tanner1-0/+5
Reject invalid cursor positions.
2016-11-06view: make viewport adjustment more robustMarc André Tanner1-1/+1
Make sure that the view_cursors_scroll_to function does not enter an infinite loop.
2016-10-27view: use more lightweight default white space replacement symbolsMarc André Tanner1-3/+3
While the replacement symbols are still not run-time configurable, the new defaults should hopefully please more people. Close #401
2016-10-03vis: improve cursor positioning after scrollingMarc André Tanner1-0/+37
Make cursor placement after scrolling (half) pages up/down less arbitrary. Close #390, fix #391
2016-09-29view: change cursor line up/down off screen movementsMarc André Tanner1-2/+12
Previously the cursor would be placed in the middle of the screen thus causing a distracting jump. Instead try to scroll the view port by only 1 line when the cursor is moved out of the visible area. The current implementation might be quite a bit slower than before, use page-wise scrolling to skip large regions. At some point we should optimize motions like 1000j. Close #301
2016-08-07view: fix screen line based motions when cursor is not visibleMarc André Tanner1-0/+4
If a cursor is not currently visible it has no associated screen line. Fallback to the corresponding logical line based variant. For example `gj` is interpreted as `j`. Fixes #354
2016-05-28vis: try to reduce number of redrawsMarc André Tanner1-0/+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-22vis: refactor status line handlingMarc André Tanner1-2/+2
Make window status bar content configurable via Lua.
2016-05-22vis: consider :set horizon setting when syntax highlightingMarc André Tanner1-11/+0
2016-05-22vis: move syntax highlighting to pure Lua codeMarc André Tanner1-183/+5
2016-05-22view: add functions to style a file rangeMarc André Tanner1-0/+35
2016-05-22ui: s/UiStyles/UiStyle/gMarc André Tanner1-1/+1
2016-05-05view: try to recover from invalid cursor positionsMarc André Tanner1-1/+4
A cursor is a mark, if the text containing the mark is removed the cursor is lost. In this case we try to fall back to the previously known cursor position/mark. This should improve undo operations for filter commands.
2016-05-04view: simplify line up/down motionsMarc André Tanner1-6/+0
As a consequence the general cursor placement code takes effect and always places the cursor in the middle of the window when moving out of the viewable range. Whether this behavior is desirable remains to be seen.
2016-05-04vis: clean up cursor column displayMarc André Tanner1-12/+4
2016-04-29view: try to improve cursor placementMarc André Tanner1-18/+21
This changes which viewport is being displayed after the primary cursor moves out of the currently viewable area. Close #164, #274, #278
2016-04-29view: improve view sliding downMarc André Tanner1-2/+4
Close #216
2016-04-27view: change view_cursors_place to take 1 based column numberMarc André Tanner1-1/+1
This should fix inconsistency in the Lua API.
2016-04-19vis: add :set horizon optionDavid B. Lamkins1-4/+13
Can be used to specify the number of bytes before the visible area to consider for syntax highlighting. Defaults to 32K for now, whereas before it was 16K.
2016-04-15view: add view_cursors_place(cursor, line, col) functionMarc André Tanner1-0/+7
2016-04-15view: add view_cursors_col functionMarc André Tanner1-0/+5
2016-04-15view: add view_cursors_line functionMarc André Tanner1-0/+5
2016-04-13view: add view_cursors_new_force functionMarc André Tanner1-3/+11
To create a cursor even if there already exists one at the same position. Should only be used if all but one of the cursors will later be removed.
2016-04-08vis: indicate primary cursor number in status barMarc André Tanner1-8/+21
If there exist multiple cursors, [n/m] is added to the status bar. Meaning the n-th cursor out of the existing m cursors is currently the primary one.
2016-04-03view: make syntax coloring more robustMarc André Tanner1-1/+3
Do not crash if for some reason view->{start,end} have outdated values.
2016-04-03view: add return value to view_cursors_disposeMarc André Tanner1-7/+8
indicating whether cursor could be removed
2016-03-30view: constify functions to manipulate selectionsMarc André Tanner1-2/+2
2016-03-30view: change internal representation of selectionsMarc André Tanner1-23/+27
We place the end mark inside the selection as opposted to on the character immediately following it. This is better when selections are touching each other. Previously for two seletions [a][b] the end mark for selection a would be at the same location as the start mark of selection b. Thus when for example the content of selection b is deleted it would also destroy selection a, because the end mark would no longer be valid.
2016-03-28vis: cleanup usage of vis_cursors_countMarc André Tanner1-1/+1
2016-03-28view: prevent creation of duplicated cursorsMarc André Tanner1-2/+8
Fail if there is already a cursor located at the requested position.
2016-03-28view: add infrastructure to iterate through cursor columnsMarc André Tanner1-0/+54
The number of columns i.e. maximal number of cursors located on the same line can be obtained by view_cursors_column_count. Column addressing is zero based, valid indexes are [0, max-1]. Assuming there is a cursor on every letter: a b c d e f g h i max column would be 3, and the following would iterate over the cursors forming the second column [c, e, h]: for (Cursor *c = view_cursors_column(view, 1); c; c = view_cursors_column_next(c, 1)) ...