aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ui-curses.c31
-rw-r--r--view.c4
-rw-r--r--vis-core.h2
-rw-r--r--vis-prompt.c8
-rw-r--r--vis.c12
5 files changed, 34 insertions, 23 deletions
diff --git a/ui-curses.c b/ui-curses.c
index fe3a966..1b01166 100644
--- a/ui-curses.c
+++ b/ui-curses.c
@@ -44,6 +44,16 @@ int ESCDELAY;
#define CONTROL(k) ((k)&0x1F)
+#ifndef DEBUG_UI
+#define DEBUG_UI 0
+#endif
+
+#if DEBUG_UI
+#define debug(...) do { printf(__VA_ARGS__); fflush(stdout); } while (0)
+#else
+#define debug(...) do { } while (0)
+#endif
+
#if 0
#define wresize(win, y, x) do { \
if (wresize(win, y, x) == ERR) { \
@@ -572,6 +582,7 @@ static bool ui_window_syntax_style(UiWin *w, int id, const char *style) {
}
static void ui_window_resize(UiCursesWin *win, int width, int height) {
+ debug("ui-win-resize[%s]: %dx%d\n", win->file->name ? win->file->name : "noname", width, height);
win->width = width;
win->height = height;
if (win->winstatus)
@@ -580,10 +591,10 @@ static void ui_window_resize(UiCursesWin *win, int width, int height) {
if (win->winside)
wresize(win->winside, height-1, win->sidebar_width);
view_resize(win->view, width - win->sidebar_width, win->winstatus ? height - 1 : height);
- view_update(win->view);
}
static void ui_window_move(UiCursesWin *win, int x, int y) {
+ debug("ui-win-move[%s]: (%d, %d)\n", win->file->name ? win->file->name : "noname", x, y);
win->x = x;
win->y = y;
mvwin(win->win, y, x + win->sidebar_width);
@@ -648,6 +659,7 @@ static void ui_window_draw(UiWin *w) {
if (!ui_window_draw_sidebar(win))
return;
+ debug("ui-win-draw[%s]\n", win->file->name ? win->file->name : "noname");
wbkgd(win->win, style_to_attr(&win->styles[UI_STYLE_DEFAULT]));
wmove(win->win, 0, 0);
int width = view_width_get(win->view);
@@ -718,6 +730,7 @@ static void ui_window_reload(UiWin *w, File *file) {
}
static void ui_window_update(UiCursesWin *win) {
+ debug("ui-win-update[%s]\n", win->file->name ? win->file->name : "noname");
if (win->winstatus)
wnoutrefresh(win->winstatus);
if (win->winside)
@@ -726,6 +739,7 @@ static void ui_window_update(UiCursesWin *win) {
}
static void ui_arrange(Ui *ui, enum UiLayout layout) {
+ debug("ui-arrange\n");
UiCurses *uic = (UiCurses*)ui;
uic->layout = layout;
int n = 0, m = !!uic->info[0], x = 0, y = 0;
@@ -769,6 +783,7 @@ static void ui_arrange(Ui *ui, enum UiLayout layout) {
}
static void ui_draw(Ui *ui) {
+ debug("ui-draw\n");
UiCurses *uic = (UiCurses*)ui;
erase();
ui_arrange(ui, uic->layout);
@@ -815,16 +830,14 @@ static void ui_resize(Ui *ui) {
static void ui_update(Ui *ui) {
UiCurses *uic = (UiCurses*)ui;
if (need_resize) {
- ui_resize(ui);
need_resize = false;
+ ui_resize(ui);
+ vis_update(uic->vis);
+ return;
}
- for (UiCursesWin *win = uic->windows; win; win = win->next) {
- if (win != uic->selwin)
- ui_window_update(win);
- }
-
- if (uic->selwin)
- ui_window_update(uic->selwin);
+ for (UiCursesWin *win = uic->windows; win; win = win->next)
+ ui_window_update(win);
+ debug("ui-doupdate\n");
doupdate();
}
diff --git a/view.c b/view.c
index 4b06d3a..33e73cd 100644
--- a/view.c
+++ b/view.c
@@ -513,6 +513,8 @@ bool view_resize(View *view, int width, int height) {
width = 1;
if (height <= 0)
height = 1;
+ if (view->width == width && view->height == height)
+ return true;
size_t lines_size = height*(sizeof(Line) + width*sizeof(Cell));
if (lines_size > view->lines_size) {
Line *lines = realloc(view->lines, lines_size);
@@ -525,6 +527,8 @@ bool view_resize(View *view, int width, int height) {
view->height = height;
memset(view->lines, 0, view->lines_size);
view_draw(view);
+ if (view->ui)
+ view_update(view);
return true;
}
diff --git a/vis-core.h b/vis-core.h
index 51c9447..9e3c4f1 100644
--- a/vis-core.h
+++ b/vis-core.h
@@ -197,7 +197,7 @@ void action_reset(Action*);
void mode_set(Vis *vis, Mode *new_mode);
void window_selection_save(Win *win);
-Win *window_new_file(Vis *vis, File *file);
+Win *window_new_file(Vis*, File*, enum UiOption);
const char *file_name_get(File*);
void file_name_set(File*, const char *name);
diff --git a/vis-prompt.c b/vis-prompt.c
index 8f7e1a9..ffe3ea2 100644
--- a/vis-prompt.c
+++ b/vis-prompt.c
@@ -152,17 +152,16 @@ static const KeyBinding prompt_backspace_binding = {
void vis_prompt_show(Vis *vis, const char *title) {
Win *active = vis->win;
- Win *prompt = window_new_file(vis, title[0] == ':' ? vis->command_file : vis->search_file);
+ Win *prompt = window_new_file(vis, title[0] == ':' ? vis->command_file : vis->search_file,
+ UI_OPTION_ONELINE);
if (!prompt)
return;
if (vis->mode->visual)
window_selection_save(active);
- view_options_set(prompt->view, UI_OPTION_ONELINE);
Text *txt = prompt->file->text;
text_insert(txt, text_size(txt), title, strlen(title));
Cursor *cursor = view_cursors_primary_get(prompt->view);
view_cursors_scroll_to(cursor, text_size(txt));
- view_draw(prompt->view);
prompt->parent = active;
prompt->parent_mode = vis->mode;
vis_window_mode_map(prompt, VIS_MODE_NORMAL, true, "<Enter>", &prompt_enter_binding);
@@ -172,7 +171,6 @@ void vis_prompt_show(Vis *vis, const char *title) {
vis_window_mode_map(prompt, VIS_MODE_INSERT, true, "<Up>", &prompt_up_binding);
vis_window_mode_map(prompt, VIS_MODE_INSERT, true, "<Backspace>", &prompt_backspace_binding);
vis_mode_switch(vis, VIS_MODE_INSERT);
- vis_draw(vis);
}
void vis_info_show(Vis *vis, const char *msg, ...) {
@@ -190,7 +188,7 @@ void vis_message_show(Vis *vis, const char *msg) {
if (!msg)
return;
if (!vis->message_window)
- vis->message_window = window_new_file(vis, vis->error_file);
+ vis->message_window = window_new_file(vis, vis->error_file, UI_OPTION_STATUSBAR);
Win *win = vis->message_window;
if (!win)
return;
diff --git a/vis.c b/vis.c
index 3b5e0d0..cdc3057 100644
--- a/vis.c
+++ b/vis.c
@@ -217,7 +217,7 @@ static void window_draw(void *ctx) {
}
}
-Win *window_new_file(Vis *vis, File *file) {
+Win *window_new_file(Vis *vis, File *file, enum UiOption options) {
Win *win = calloc(1, sizeof(Win));
if (!win)
return NULL;
@@ -228,7 +228,7 @@ Win *window_new_file(Vis *vis, File *file) {
win->event.draw = window_draw;
win->horizon = 1 << 15;
win->view = view_new(file->text, &win->event);
- win->ui = vis->ui->window_new(vis->ui, win->view, file, UI_OPTION_STATUSBAR);
+ win->ui = vis->ui->window_new(vis->ui, win->view, file, options);
if (!win->jumplist || !win->view || !win->ui) {
window_free(win);
return NULL;
@@ -267,7 +267,7 @@ bool vis_window_reload(Win *win) {
}
bool vis_window_split(Win *original) {
- Win *win = window_new_file(original->vis, original->file);
+ Win *win = window_new_file(original->vis, original->file, UI_OPTION_STATUSBAR);
if (!win)
return false;
for (size_t i = 0; i < LENGTH(win->modes); i++) {
@@ -281,7 +281,6 @@ bool vis_window_split(Win *original) {
vis_window_syntax_set(win, vis_window_syntax_get(original));
view_options_set(win->view, view_options_get(original->view));
view_cursor_to(win->view, view_cursor_get(original->view));
- vis_draw(win->vis);
return true;
}
@@ -344,7 +343,6 @@ void vis_redraw(Vis *vis) {
void vis_update(Vis *vis) {
for (Win *win = vis->windows; win; win = win->next)
view_update(win->view);
- view_update(vis->win->view);
vis->ui->update(vis->ui);
}
@@ -356,14 +354,12 @@ bool vis_window_new(Vis *vis, const char *filename) {
File *file = file_new(vis, filename);
if (!file)
return false;
- Win *win = window_new_file(vis, file);
+ Win *win = window_new_file(vis, file, UI_OPTION_STATUSBAR);
if (!win) {
file_free(vis, file);
return false;
}
- vis_draw(vis);
-
return true;
}