some little fix

This commit is contained in:
Ilia Maslakov 2009-05-06 06:12:01 +00:00
parent d323924979
commit 074337e0df
4 changed files with 46 additions and 9 deletions

View File

@ -324,7 +324,6 @@ int book_mark_get_collapse_state (GList * list, const int line)
int c = 0; int c = 0;
c = book_mark_collapse_query (list, line, &start_line, &end_line, &state); c = book_mark_collapse_query (list, line, &start_line, &end_line, &state);
// mc_log("start_line: %ld, end_line: %ld, line: %ld [%i]\n", start_line, end_line, line, c);
if ( c == 0 ) if ( c == 0 )
return C_LINES_DEFAULT; return C_LINES_DEFAULT;
if ( line == start_line ) { if ( line == start_line ) {
@ -348,7 +347,7 @@ int book_mark_get_collapse_state (GList * list, const int line)
} }
/* shift down bookmarks after this line */ /* shift down collapse after this line */
void book_mark_collapse_inc (GList * list, int line) void book_mark_collapse_inc (GList * list, int line)
{ {
GList *cl, *l; GList *cl, *l;
@ -366,6 +365,45 @@ void book_mark_collapse_inc (GList * list, int line)
} else if ( collapsed->end_line >= line ){ } else if ( collapsed->end_line >= line ){
collapsed->end_line++; collapsed->end_line++;
} }
cl = g_list_next (cl);
} }
} }
/* shift up collapse after this line */
void book_mark_collapse_dec (GList * list, int line)
{
GList *cl, *l, *tmp;
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--;
}
cl = g_list_next (cl);
}
/* remove demage region */
/*
cl = g_list_last (list);
while ( cl ) {
collapsed = (struct collapsed_lines *) cl->data;
if ( abs (collapsed->start_line - collapsed->end_line) < 2 ) {
g_free (cl->data);
tmp = g_list_remove_link (list, cl);
g_list_free_1 (cl);
}
cl = g_list_previous (cl);
}
*/
}

View File

@ -1122,6 +1122,8 @@ int edit_delete (WEdit * edit, const int byte_delete)
if (p == '\n') { if (p == '\n') {
if (edit->book_mark) if (edit->book_mark)
book_mark_dec (edit, edit->curs_line); book_mark_dec (edit, edit->curs_line);
if (edit->collapsed)
book_mark_collapse_dec (edit->collapsed, edit->curs_line);
edit->total_lines--; edit->total_lines--;
edit->force |= REDRAW_AFTER_CURSOR; edit->force |= REDRAW_AFTER_CURSOR;
} }
@ -1169,6 +1171,8 @@ edit_backspace (WEdit * edit, const int byte_delete)
if (p == '\n') { if (p == '\n') {
if (edit->book_mark) if (edit->book_mark)
book_mark_dec (edit, edit->curs_line); book_mark_dec (edit, edit->curs_line);
if (edit->collapsed)
book_mark_collapse_dec (edit->collapsed, edit->curs_line);
edit->curs_line--; edit->curs_line--;
edit->total_lines--; edit->total_lines--;
edit->force |= REDRAW_AFTER_CURSOR; edit->force |= REDRAW_AFTER_CURSOR;
@ -2687,14 +2691,13 @@ edit_execute_cmd (WEdit *edit, int command, int char_for_insertion)
int upto_start = edit_count_lines (edit, start_mark, edit->curs1); int upto_start = edit_count_lines (edit, start_mark, edit->curs1);
int lines_selected = edit_count_lines (edit, start_mark, edit->curs1); int lines_selected = edit_count_lines (edit, start_mark, edit->curs1);
int start_line = edit->curs_line; int start_line = edit->curs_line;
mc_log("start_mark:%i \n", start_mark);
if ( edit->curs1 > edit->mark1 ) { if ( edit->curs1 > edit->mark1 ) {
start_line = edit->curs_line - upto_start; start_line = edit->curs_line - upto_start;
} else { } else {
start_line = edit->curs_line + upto_start; start_line = edit->curs_line + upto_start;
} }
unsigned int end_line = start_line + lines_selected; unsigned int end_line = start_line + lines_selected;
edit->collapsed = book_mark_collapse_insert (edit->collapsed, start_line, end_line, 0); edit->collapsed = book_mark_collapse_insert (edit->collapsed, start_line, end_line, 1);
} }
edit->force |= REDRAW_PAGE; edit->force |= REDRAW_PAGE;
break; break;

View File

@ -257,6 +257,7 @@ int book_mark_collapse_query (GList *list, const int 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); void book_mark_collapse_inc (GList * list, int line);
void book_mark_collapse_dec (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);

View File

@ -332,11 +332,6 @@ print_to_widget (WEdit *edit, long row, int start_col, int start_col_real,
int visible_tabs = 1, visible_tws = 1; int visible_tabs = 1, visible_tws = 1;
/* b is a pointer to the beginning of the line */ /* b is a pointer to the beginning of the line */
/* collapse_state = -1 first elapsed line */
/* collapse_state = 1 first collapsed line */
/* collapse_state = 2 in middle collapsed lines */
/* collapse_state = 3 last collapsed line */
/* collapse_state = 0 not collapsed */
static void static void
edit_draw_this_line (WEdit *edit, long b, long row, long start_col, edit_draw_this_line (WEdit *edit, long b, long row, long start_col,
long end_col, int collapse_state) long end_col, int collapse_state)