Skip to content

Commit

Permalink
Restructure display code
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
martanne committed Mar 14, 2017
1 parent bed289a commit 9bcf266
Show file tree
Hide file tree
Showing 18 changed files with 1,306 additions and 1,122 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ REGEX_SRC ?= text-regex.c

SRC = array.c buffer.c libutf.c main.c map.c register.c ring-buffer.c \
sam.c text.c text-motions.c text-objects.c text-util.c \
ui-curses.c view.c vis.c vis-lua.c vis-modes.c vis-motions.c \
ui-terminal.c view.c vis.c vis-lua.c vis-modes.c vis-motions.c \
vis-operators.c vis-prompt.c vis-text-objects.c $(REGEX_SRC)

ELF = vis vis-menu vis-digraph
Expand Down
7 changes: 6 additions & 1 deletion lua/themes/dark-16.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- Eight-color scheme
local lexers = vis.lexers
-- dark
lexers.STYLE_DEFAULT = 'back:black,fore:white'
lexers.STYLE_DEFAULT ='back:black,fore:white'
lexers.STYLE_NOTHING = 'back:black'
lexers.STYLE_CLASS = 'fore:yellow,bold'
lexers.STYLE_COMMENT = 'fore:blue,bold'
Expand Down Expand Up @@ -29,3 +29,8 @@ lexers.STYLE_CURSOR_PRIMARY = lexers.STYLE_CURSOR..',fore:yellow'
lexers.STYLE_CURSOR_LINE = 'underlined'
lexers.STYLE_COLOR_COLUMN = 'back:red'
lexers.STYLE_SELECTION = 'back:white'
lexers.STYLE_STATUS = 'reverse'
lexers.STYLE_STATUS_FOCUSED = 'reverse,bold'
lexers.STYLE_SEPARATOR = lexers.STYLE_DEFAULT
lexers.STYLE_INFO = 'fore:default,back:default,bold'
lexers.STYLE_EOF = ''
5 changes: 5 additions & 0 deletions lua/themes/light-16.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,8 @@ lexers.STYLE_CURSOR_PRIMARY = lexers.STYLE_CURSOR..',fore:yellow'
lexers.STYLE_CURSOR_LINE = 'underlined'
lexers.STYLE_COLOR_COLUMN = 'back:red'
lexers.STYLE_SELECTION = 'back:black'
lexers.STYLE_STATUS = 'reverse'
lexers.STYLE_STATUS_FOCUSED = 'reverse,bold'
lexers.STYLE_SEPARATOR = lexers.STYLE_DEFAULT
lexers.STYLE_INFO = 'fore:default,back:default,bold'
lexers.STYLE_EOF = ''
5 changes: 5 additions & 0 deletions lua/themes/solarized.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,8 @@ lexers.STYLE_CURSOR_LINE = 'back:'..colors.base02
lexers.STYLE_COLOR_COLUMN = 'back:'..colors.base02
-- lexers.STYLE_SELECTION = 'back:'..colors.base02
lexers.STYLE_SELECTION = 'back:white'
lexers.STYLE_STATUS = 'back:black,fore:white'
lexers.STYLE_STATUS_FOCUSED = lexers.STYLE_STATUS..',bold'
lexers.STYLE_SEPARATOR = lexers.STYLE_DEFAULT
lexers.STYLE_INFO = 'fore:default,back:default,bold'
lexers.STYLE_EOF = ''
5 changes: 5 additions & 0 deletions lua/vis-std.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ vis.events.subscribe(vis.events.WIN_SYNTAX, function(win, name)
win:style_define(win.STYLE_SELECTION, lexers.STYLE_SELECTION or '')
win:style_define(win.STYLE_LINENUMBER, lexers.STYLE_LINENUMBER or '')
win:style_define(win.STYLE_COLOR_COLUMN, lexers.STYLE_COLOR_COLUMN or '')
win:style_define(win.STYLE_STATUS, lexers.STYLE_STATUS or '')
win:style_define(win.STYLE_STATUS_FOCUSED, lexers.STYLE_STATUS_FOCUSED or '')
win:style_define(win.STYLE_SEPARATOR, lexers.STYLE_SEPARATOR or '')
win:style_define(win.STYLE_INFO, lexers.STYLE_INFO or '')
win:style_define(win.STYLE_EOF, lexers.STYLE_EOF or '')

if name == nil then return true end

Expand Down
5 changes: 3 additions & 2 deletions main.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#include <signal.h>
#include <limits.h>
#include <string.h>
#include <stdio.h>
#include <wchar.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>

#include "ui-curses.h"
#include "ui-terminal.h"
#include "vis.h"
#include "vis-lua.h"
#include "text-util.h"
Expand Down Expand Up @@ -2001,7 +2002,7 @@ int main(int argc, char *argv[]) {
.win_status = vis_lua_win_status,
};

vis = vis_new(ui_curses_new(), &event);
vis = vis_new(ui_term_new(), &event);
if (!vis)
return EXIT_FAILURE;

Expand Down
Loading

0 comments on commit 9bcf266

Please sign in to comment.