aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2015-11-28 18:45:07 +0100
committerMarc André Tanner <mat@brain-dump.org>2015-11-28 20:09:15 +0100
commitb1c462beb8b9e0bae7f8886054eee2fe361149a8 (patch)
tree8fc350e8d1bde3b3bc530969bfaa24e485ab87a9
parent30e9673fdb22905df853ef07b3826fa19b28831c (diff)
downloadvis-b1c462beb8b9e0bae7f8886054eee2fe361149a8.tar.gz
vis-b1c462beb8b9e0bae7f8886054eee2fe361149a8.tar.xz
view: remove ViewEvent infrastructure
The only used event handler was used to update the '< and '> marks which is now taken care of by the leave handler of the visual modes.
-rw-r--r--view.c7
-rw-r--r--view.h7
-rw-r--r--vis-cmds.c2
-rw-r--r--vis-core.h1
-rw-r--r--vis.c16
5 files changed, 5 insertions, 28 deletions
diff --git a/view.c b/view.c
index dfb4c57..4e3f869 100644
--- a/view.c
+++ b/view.c
@@ -67,7 +67,6 @@ struct Cursor { /* cursor position */
struct View {
Text *text; /* underlying text management */
UiWin *ui;
- ViewEvent *events;
int width, height; /* size of display area */
Filepos start, end; /* currently displayed area [start, end] in bytes from the start of the file */
Filepos start_last; /* previously used start of visible area, used to update the mark */
@@ -580,9 +579,6 @@ void view_update(View *view) {
}
}
}
-
- if (view->events && view->events->selection)
- view->events->selection(view->events->data, &sel);
}
}
@@ -637,7 +633,7 @@ void view_reload(View *view, Text *text) {
view_cursor_to(view, 0);
}
-View *view_new(Text *text, lua_State *lua, ViewEvent *events) {
+View *view_new(Text *text, lua_State *lua) {
if (!text)
return NULL;
View *view = calloc(1, sizeof(View));
@@ -650,7 +646,6 @@ View *view_new(Text *text, lua_State *lua, ViewEvent *events) {
view->text = text;
view->lua = lua;
- view->events = events;
view->tabwidth = 8;
view_options_set(view, 0);
diff --git a/view.h b/view.h
index 4447dd7..25b186f 100644
--- a/view.h
+++ b/view.h
@@ -13,11 +13,6 @@ typedef struct Cursor Cursor;
typedef struct Selection Selection;
typedef struct {
- void *data;
- void (*selection)(void *data, Filerange*);
-} ViewEvent;
-
-typedef struct {
int width; /* display width i.e. number of columns ocupied by this character */
size_t len; /* number of bytes the character displayed in this cell uses, for
character which use more than 1 column to display, their lenght
@@ -45,7 +40,7 @@ typedef struct {
size_t col;
} CursorPos;
-View *view_new(Text*, lua_State*, ViewEvent*);
+View *view_new(Text*, lua_State*);
void view_ui(View*, UiWin*);
/* change associated text displayed in this window */
void view_reload(View*, Text*);
diff --git a/vis-cmds.c b/vis-cmds.c
index 58b611d..21529a9 100644
--- a/vis-cmds.c
+++ b/vis-cmds.c
@@ -365,7 +365,7 @@ static const char *file_open_dialog(Vis *vis, const char *pattern) {
Text *txt_orig = file->text;
View *view_orig = win->view;
Text *txt = text_load(NULL);
- View *view = view_new(txt, NULL, NULL);
+ View *view = view_new(txt, NULL);
filename[0] = '\0';
snprintf(vis_open, sizeof(vis_open)-1, "vis-open %s", pattern ? pattern : "");
diff --git a/vis-core.h b/vis-core.h
index 614a206..1ecc1b6 100644
--- a/vis-core.h
+++ b/vis-core.h
@@ -117,7 +117,6 @@ struct Win {
UiWin *ui; /* ui object handling visual appearance of this window */
File *file; /* file being displayed in this window */
View *view; /* currently displayed part of underlying text */
- ViewEvent events;
RingBuffer *jumplist; /* LRU jump management */
ChangeList changelist; /* state for iterating through least recently changes */
Win *prev, *next; /* neighbouring windows */
diff --git a/vis.c b/vis.c
index c37dc28..f825862 100644
--- a/vis.c
+++ b/vis.c
@@ -158,14 +158,6 @@ static void windows_invalidate(Vis *vis, size_t start, size_t end) {
view_draw(vis->win->view);
}
-static void window_selection_changed(void *win, Filerange *sel) {
- File *file = ((Win*)win)->file;
- if (text_range_valid(sel)) {
- file->marks[MARK_SELECTION_START] = text_mark_set(file->text, sel->start);
- file->marks[MARK_SELECTION_END] = text_mark_set(file->text, sel->end);
- }
-}
-
static void window_free(Win *win) {
if (!win)
return;
@@ -183,12 +175,8 @@ static Win *window_new_file(Vis *vis, File *file) {
return NULL;
win->vis = vis;
win->file = file;
- win->events = (ViewEvent) {
- .data = win,
- .selection = window_selection_changed,
- };
win->jumplist = ringbuf_alloc(31);
- win->view = view_new(file->text, vis->lua, &win->events);
+ win->view = view_new(file->text, vis->lua);
win->ui = vis->ui->window_new(vis->ui, win->view, file);
if (!win->jumplist || !win->view || !win->ui) {
window_free(win);
@@ -382,7 +370,7 @@ Vis *vis_new(Ui *ui) {
goto err;
if (!(vis->prompt->file->text = text_load(NULL)))
goto err;
- if (!(vis->prompt->view = view_new(vis->prompt->file->text, NULL, NULL)))
+ if (!(vis->prompt->view = view_new(vis->prompt->file->text, NULL)))
goto err;
if (!(vis->prompt->ui = vis->ui->prompt_new(vis->ui, vis->prompt->view, vis->prompt->file)))
goto err;