Compare commits

...

2 Commits

Author SHA1 Message Date
ailin-nemui
fadf0bac18 wip 2019-10-15 16:17:39 +02:00
ailin-nemui
a67775db88 [wip] fix lastlog -clear not resetting /clear 2019-10-15 16:17:39 +02:00

View File

@ -1171,26 +1171,85 @@ static void view_remove_line_update_startline(TEXT_BUFFER_VIEW_REC *view,
LINE_REC *line, int linecount) LINE_REC *line, int linecount)
{ {
int scroll; int scroll;
GString *line_text;
line_text = g_string_new(NULL);
if (view->startline != NULL)
textbuffer_line2text(view->startline, FALSE, line_text);
fprintf(stderr, "view_remove_line_update_startline\n"
".. height: %d\n"
".. ypos: %d\n"
".. subline: %d\n"
"..empty_linecount: %d\n"
".. startline: %s\n",
view->height, view->ypos, view->subline, view->empty_linecount, line_text->str);
g_string_truncate(line_text, 0);
if (line != NULL)
textbuffer_line2text(line, FALSE, line_text);
fprintf(stderr,
".. line: %s\n", line_text->str);
g_string_truncate(line_text, 0);
if (view->startline == line) { if (view->startline == line) {
view->startline = view->startline->prev != NULL ? view->startline = view->startline->prev != NULL ?
view->startline->prev : view->startline->next; view->startline->prev : view->startline->next;
view->subline = 0; view->subline = 0;
if (view->startline != NULL)
textbuffer_line2text(view->startline, FALSE, line_text);
fprintf(stderr, "... moving startline ...\n"
".. subline: %d\n"
".. startline: %s\n",
view->subline, line_text->str);
g_string_truncate(line_text, 0);
} else { } else {
scroll = view->height - scroll = view->height -
view_get_lines_height(view, view->startline, view_get_lines_height(view, view->startline,
view->subline, line); view->subline, line);
if (scroll > 0) { fprintf(stderr, "... other line ...\n"
".. scroll: %d\n",
scroll);
if (view->empty_linecount > 0) {
view->empty_linecount = scroll;
if (view->empty_linecount < 0)
view->empty_linecount = 0;
else if (view->empty_linecount > view->height)
view->empty_linecount = view->height;
fprintf(stderr, "... changing empty_linecount ...\n"
"..empty_linecount: %d\n",
view->empty_linecount);
} else if (scroll > 0) {
view_scroll(view, &view->startline, view_scroll(view, &view->startline,
&view->subline, -scroll, FALSE); &view->subline, -scroll, FALSE);
textbuffer_line2text(view->startline, FALSE, line_text);
fprintf(stderr, "... scrolling ...\n"
".. subline: %d\n"
".. startline: %s\n",
view->subline, line_text->str);
g_string_truncate(line_text, 0);
} }
} }
fprintf(stderr,
".. linecount: %d\n",
linecount);
/* FIXME: this is slow and unnecessary, but it's easy and /* FIXME: this is slow and unnecessary, but it's easy and
really works :) */ really works :) */
textbuffer_view_init_ypos(view); textbuffer_view_init_ypos(view);
if (textbuffer_line_exists_after(view->startline, line)) fprintf(stderr, "... init_ypos ...\n"
".. ypos: %d\n",
view->ypos);
if (textbuffer_line_exists_after(view->startline, line)) {
view->ypos -= linecount; view->ypos -= linecount;
fprintf(stderr, "... moving ypos by linecount ...\n"
".. ypos: %d\n",
view->ypos);
}
g_string_free(line_text, TRUE);
fprintf(stderr, "\n");
} }
static void view_remove_line(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line, static void view_remove_line(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line,
@ -1242,7 +1301,9 @@ static void view_remove_line(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line,
realcount = view_scroll(view, &view->bottom_startline, realcount = view_scroll(view, &view->bottom_startline,
&view->bottom_subline, &view->bottom_subline,
-linecount, FALSE); -linecount, FALSE);
fprintf(stderr, "adjusting empty_linecount [ %d -> ", view->empty_linecount);
view->empty_linecount += linecount-realcount; view->empty_linecount += linecount-realcount;
fprintf(stderr, "%d , linecount: %d, realcount: %d ]\n", view->empty_linecount, linecount, realcount);
} }
if (view->bottom_startline == line) { if (view->bottom_startline == line) {
@ -1298,17 +1359,17 @@ void textbuffer_view_remove_line(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line)
void textbuffer_view_remove_lines_by_level(TEXT_BUFFER_VIEW_REC *view, int level) void textbuffer_view_remove_lines_by_level(TEXT_BUFFER_VIEW_REC *view, int level)
{ {
LINE_REC *line, *next; LINE_REC *line, *prev;
term_refresh_freeze(); term_refresh_freeze();
line = textbuffer_view_get_lines(view); line = textbuffer_line_last(view->buffer);
while (line != NULL) { while (line != NULL) {
next = line->next; prev = line->prev;
if (line->info.level & level) if (line->info.level & level)
textbuffer_view_remove_line(view, line); textbuffer_view_remove_line(view, line);
line = next; line = prev;
} }
textbuffer_view_redraw(view); textbuffer_view_redraw(view);
term_refresh_thaw(); term_refresh_thaw();
@ -1467,9 +1528,47 @@ static int sig_check_linecache(void)
return 1; return 1;
} }
#include "gui-windows.h"
#include "commands.h"
static void cmd_window_vi(const char *data)
{
GUI_WINDOW_REC *gui;
TEXT_BUFFER_VIEW_REC *view;
GString *line_text;
gui = WINDOW_GUI(active_win);
view = gui->view;
line_text = g_string_new(NULL);
if (view->startline != NULL)
textbuffer_line2text(view->startline, FALSE, line_text);
fprintf(stderr, "VIEW INFO\n"
".. height: %d\n"
".. ypos: %d\n"
".. subline: %d\n"
"..empty_linecount: %d\n"
".. bottom: %s\n"
".. startline: %s\n"
".. bottom_subline: %d\n",
view->height, view->ypos, view->subline, view->empty_linecount, view->bottom ? "TRUE" : "FALSE", line_text->str,
view->bottom_subline);
g_string_truncate(line_text, 0);
if (view->bottom_startline != NULL)
textbuffer_line2text(view->bottom_startline, FALSE, line_text);
fprintf(stderr,
"..bottom_startine: %s\n",
line_text->str);
g_string_free(line_text, TRUE);
fprintf(stderr, "\n");
}
void textbuffer_view_init(void) void textbuffer_view_init(void)
{ {
linecache_tag = g_timeout_add(LINE_CACHE_CHECK_TIME, (GSourceFunc) sig_check_linecache, NULL); linecache_tag = g_timeout_add(LINE_CACHE_CHECK_TIME, (GSourceFunc) sig_check_linecache, NULL);
command_bind("window vi", NULL, (SIGNAL_FUNC) cmd_window_vi);
} }
void textbuffer_view_deinit(void) void textbuffer_view_deinit(void)