add bookmark_collapse_inc

This commit is contained in:
Ilia Maslakov 2009-05-06 04:39:07 +00:00
parent 9a1f3a3ac5
commit d323924979
3 changed files with 28 additions and 0 deletions

View File

@ -346,3 +346,26 @@ int book_mark_get_collapse_state (GList * list, const int line)
return C_LINES_LAST; return C_LINES_LAST;
} }
} }
/* shift down bookmarks after this line */
void book_mark_collapse_inc (GList * list, int line)
{
GList *cl, *l;
struct collapsed_lines *collapsed;
l = list;
if (!l)
return;
l = g_list_first (list);
cl = l;
while (cl) {
collapsed = (struct collapsed_lines *) cl->data;
if ( collapsed->start_line >= line ) {
collapsed->start_line++;
collapsed->end_line++;
} else if ( collapsed->end_line >= line ){
collapsed->end_line++;
}
}
}

View File

@ -1019,6 +1019,8 @@ edit_insert (WEdit *edit, int c)
if (c == '\n') { if (c == '\n') {
if (edit->book_mark) if (edit->book_mark)
book_mark_inc (edit, edit->curs_line); book_mark_inc (edit, edit->curs_line);
if (edit->collapsed)
book_mark_collapse_inc(edit->collapsed, edit->curs_line);
edit->curs_line++; edit->curs_line++;
edit->total_lines++; edit->total_lines++;
edit->force |= REDRAW_LINE_ABOVE | REDRAW_AFTER_CURSOR; edit->force |= REDRAW_LINE_ABOVE | REDRAW_AFTER_CURSOR;
@ -1064,6 +1066,8 @@ void edit_insert_ahead (WEdit * edit, int c)
if (c == '\n') { if (c == '\n') {
if (edit->book_mark) if (edit->book_mark)
book_mark_inc (edit, edit->curs_line); book_mark_inc (edit, edit->curs_line);
if (edit->collapsed)
book_mark_collapse_inc(edit->collapsed, edit->curs_line);
edit->total_lines++; edit->total_lines++;
edit->force |= REDRAW_AFTER_CURSOR; edit->force |= REDRAW_AFTER_CURSOR;
} }

View File

@ -256,6 +256,7 @@ int book_mark_collapse_query (GList *list, const int line,
int *end_line, int *end_line,
int *state); int *state);
int book_mark_get_collapse_state (GList *list, const int line); int book_mark_get_collapse_state (GList *list, const int line);
void book_mark_collapse_inc (GList * list, int line);
int line_is_blank (WEdit *edit, long line); int line_is_blank (WEdit *edit, long line);
int edit_indent_width (WEdit *edit, long p); int edit_indent_width (WEdit *edit, long p);