diff options
| author | Randy Palamar <randy@rnpnr.xyz> | 2024-05-21 11:27:08 -0600 |
|---|---|---|
| committer | Randy Palamar <randy@rnpnr.xyz> | 2024-05-21 20:21:46 -0600 |
| commit | 7554ecd77efc29601b7b44deca602724917ce019 (patch) | |
| tree | 9e8e7d0ca7f0b173f98c224a25f6f626dcece8ac /view.c | |
| parent | 7e85064ac77ea43e84d88eb910b0adb6f07d5d12 (diff) | |
| download | vis-7554ecd77efc29601b7b44deca602724917ce019.tar.gz vis-7554ecd77efc29601b7b44deca602724917ce019.tar.xz | |
remove some view pointer chasing
Same as previous commit each window only has a single View. No
need for it to be stored elsewhere in memory.
Diffstat (limited to 'view.c')
| -rw-r--r-- | view.c | 19 |
1 files changed, 7 insertions, 12 deletions
@@ -71,7 +71,7 @@ void window_status_update(Vis *vis, Win *win) { size_t left_count = 0; size_t right_count = 0; - View *view = win->view; + View *view = &win->view; File *file = win->file; Text *txt = file->text; int width = win->ui->width; @@ -114,12 +114,12 @@ void window_status_update(Vis *vis, Win *win) { "%zu%%", percent); if (!(options & UI_OPTION_LARGE_FILE)) { - Selection *sel = view_selections_primary_get(win->view); + Selection *sel = view_selections_primary_get(&win->view); size_t line = view_cursors_line(sel); size_t col = view_cursors_col(sel); if (col > UI_LARGE_FILE_LINE_SIZE) { options |= UI_OPTION_LARGE_FILE; - view_options_set(win->view, options); + view_options_set(&win->view, options); } snprintf(right_parts[right_count++], sizeof(right_parts[0]), "%zu, %zu", line, col); @@ -551,7 +551,6 @@ void view_free(View *view) { free(view->textbuf); free(view->lines); free(view->breakat); - free(view); } void view_reload(View *view, Text *text) { @@ -560,12 +559,9 @@ void view_reload(View *view, Text *text) { view_cursors_to(view->selection, 0); } -View *view_new(Text *text) { +bool view_init(View *view, Text *text) { if (!text) - return NULL; - View *view = calloc(1, sizeof(View)); - if (!view) - return NULL; + return false; view->text = text; view->tabwidth = 8; @@ -582,12 +578,11 @@ View *view_new(Text *text) { !view_selections_new(view, 0) || !view_resize(view, 1, 1)) { - view_free(view); - return NULL; + return false; } view_cursors_to(view->selection, 0); - return view; + return true; } static size_t cursor_set(Selection *sel, Line *line, int col) { |
