aboutsummaryrefslogtreecommitdiff
path: root/ui-curses.c
AgeCommit message (Collapse)AuthorFilesLines
2017-03-14Restructure display codeMarc André Tanner1-970/+0
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-01-31vis: add workaround for broken color handling in Terminal.appMarc André Tanner1-9/+10
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-11ui: improve editor suspensionMarc André Tanner1-1/+1
Send SIGSTOP to process group. This should fix job control when launched from a script.
2017-01-07ui: improve color palette resetMarc André Tanner1-46/+9
Do not restore color palette for :! commands (i.e. in ui_terminal_save). By far the most common use of this is to invoke vis-menu(1) (e.g. indirectly through `:open .` or for word completion). Restoring the palette in this case also affects the file content still being visible above the menu thus causing weird display artifacts. Use the OSC 104 escape sequence to reset color palette. This should respect custom color profiles.
2017-01-05ui: remove now unused codeMarc André Tanner1-37/+4
2017-01-05ui: replace lookup tables with algorithmS. Gilles1-269/+44
The algorithm for computing the [16,256) range of the `standard' 256 colors comes from 256colors.pl from XFree86's xterm tree, which appears to have given rise to the standard colors.
2017-01-05ui: Turn palette on/off when saving/restoring terminalS. Gilles1-12/+46
2017-01-01ui: use accurate colors when availableS. Gilles1-1/+44
When ncurses reports can_change_color(), have color_find_rgb() define use the exact color requested by modifying ncurses' current palette. Make an honest effort at restoring this palette on shutdown, though we can't be positive it's correct.
2017-01-01ui: move color_from_256 to file scopeS. Gilles1-122/+123
2016-12-20ui: increase maximum info message lengthMarc André Tanner1-1/+1
2016-11-27vis: cleanup signal handling codeMarc André Tanner1-35/+0
Move all signal handling code out of "library" code into user application.
2016-11-27vis: install SIGTERM handler to properly restore terminal when being killedMarc André Tanner1-19/+33
2016-11-27ui: remove terminal restore codeMarc André Tanner1-4/+0
This is already taken care of by libtermkey. Also we did not check whether we actually had a valid state to restore.
2016-11-22ui: remove $ESCDELAY handlingMarc André Tanner1-9/+0
We are no longer using curses for input handling, hence this code is obsolete.
2016-11-16ui: work around libtermkey bug when stdin is /dev/nullMarc André Tanner1-20/+36
Libtermkey tries to write a terminal initialization sequence even when stdin is not a terminal as is the case when running `vis < /dev/null` or within the Travis CI environment. The broken code is in libtermkey's driver-ti.c function `start_driver`: /* There's no point trying to write() to a pipe */ if(fstat(tk->fd, &statbuf) == -1) return 0; if(S_ISFIFO(statbuf.st_mode)) return 1; Instead they should simply be using isatty(3). As a workaround we catch the resulting EBADF failure and try to re-open /dev/tty as stdin. If this fails too (as is the case in the Mac OS X Travis CI runner) create an abstract termkey instance instead. In this state vis will not be able to consume any input and will instead spin with 100% CPU usage in the mainloop. This is solely done to make the Lua tests, which control vis through other means, work within the Travis CI environment.
2016-11-15vis: defer UI initialization and overhaul argument parsingMarc André Tanner1-32/+24
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: move initial theme loading code to luaMarc André Tanner1-10/+0
2016-11-14vis-lua: add vis.ui.colors denoting the number of available colorsMarc André Tanner1-0/+5
2016-11-14ui: remove unused functionMarc André Tanner1-10/+0
2016-11-02ui: correctly display cell attributesMarc André Tanner1-1/+1
When multiple selections are being displayed and the selection orientation is changed, the complete primary selection was wrongly colored in the style of the primary cursor.
2016-10-28ui: allow cursor line style to override cell attributesMarc André Tanner1-2/+3
Up until now only the background color could be changed.
2016-10-27vis: apply language map only to key values not modifiersMarc André Tanner1-11/+5
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-05Fix various issues reported by coverity scanMarc André Tanner1-1/+3
2016-10-05ui: fix resource leak, close file descriptorMarc André Tanner1-0/+1
2016-05-28vis: try to reduce number of redrawsMarc André Tanner1-9/+22
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-26ui: properly redraw status line when window focus changesMarc André Tanner1-1/+4
2016-05-22vis: refactor status line handlingMarc André Tanner1-42/+0
Make window status bar content configurable via Lua.
2016-05-22vis: add function to change window statusbar contentMarc André Tanner1-0/+13
2016-05-22vis: add functions to query window sizeMarc André Tanner1-0/+10
2016-05-22ui: s/UiStyles/UiStyle/gMarc André Tanner1-1/+1
2016-05-10Revert "vis: clean up interaction between vis and ui"Marc André Tanner1-5/+15
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-04vis: enable large file optimizations for files with long linesMarc André Tanner1-3/+11
2016-05-04vis: clean up cursor column displayMarc André Tanner1-7/+11
2016-05-04vis: clean up interaction between vis and uiMarc André Tanner1-15/+5
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: re-open stdin as /dev/tty when reaching EOFMarc André Tanner1-3/+40
This handles (notices the missing - at the end of the command line): $ printf ":new\n" | vis more gracefully. This instructs vis to read commands (not file content) from stdin. Once all input from stdin is consumed we open /dev/tty and start processing regular keyboard input instead.
2016-04-17vis: indicate primary cursor by using a different color instead of blinkingMarc André Tanner1-4/+1
Blinking caused more problems (#251, #202) than it solved. Blank cells were especially problematic.
2016-04-08vis: let :e recreate a window at the same location as the old oneMarc André Tanner1-0/+31
Close #224
2016-04-08vis: indicate primary cursor number in status barMarc André Tanner1-6/+12
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-03-23Remove identically replicated copyright comments from source filesMarc André Tanner1-15/+1
2016-03-12ui/view: general code cleanupMarc André Tanner1-5/+10
2016-03-12ui: use correct default cell styleMarc André Tanner1-1/+4
This is important for files without associated syntax highlighting. The selections should now again be visible.
2016-03-12ui: make primary cursor blink even if no lua theme has been loadedMarc André Tanner1-4/+4
2016-03-11ui: also blink primary cursor if it is on a blank cellMarc André Tanner1-1/+4
2016-03-10view: add query function for multiple cursorsMarc André Tanner1-1/+1
2016-03-10ui: make primary cursor blinkMarc André Tanner1-1/+5
2016-03-10ui: add support for blink style attributeMarc André Tanner1-0/+4
2016-02-12Improve large file supportMarc André Tanner1-7/+10
Disable absolute line numbers for large files (currently anything bigger than 32MiB). This speeds up moving around with for example nn% since no new lines need to be calculated. Of course movements like :nn will be unaffected. The optimizations can be disabled by explicitly enabling absolute line numbers as in :set number
2016-01-30Improve Lua error reportingMarc André Tanner1-0/+6
Display Lua errors in a dedicated window/file. A typo or missing dependency (e.g. lpeg) in visrc.lua will no longer silently fail without any indication. The Lua integration in view.h is not yet converted.
2016-01-17ui: display current line number instead of relative 0Marc André Tanner1-3/+5
2016-01-17ui: support color definitions in terms of the 256 color paletteMarc André Tanner1-0/+3