diff options
| -rw-r--r-- | view.c | 7 | ||||
| -rw-r--r-- | view.h | 7 | ||||
| -rw-r--r-- | vis-cmds.c | 2 | ||||
| -rw-r--r-- | vis-core.h | 1 | ||||
| -rw-r--r-- | vis.c | 16 |
5 files changed, 5 insertions, 28 deletions
@@ -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); @@ -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*); @@ -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 : ""); @@ -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 */ @@ -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; |
