Fixed problems with markers where Edit All did not behave the same for every marker and deleting selections that intersect markers did not remove the marker in all cases.

This commit is contained in:
Ian Thompson
2008-08-16 20:31:38 +00:00
parent 310a6e2179
commit 9b6dffad2d
2 changed files with 20 additions and 8 deletions

View File

@@ -989,8 +989,12 @@ static void txt_delete_sel (Text *text)
if (text->curl != text->sell) {
txt_clear_marker_region(text, text->curl, text->curc, text->curl->len, 0);
move= txt_get_span(text->curl, text->sell);
} else
} else {
mrk= txt_find_marker_region(text, text->curl, text->curc, text->selc, 0);
if (mrk->start > text->curc || mrk->end < text->selc)
txt_clear_marker_region(text, text->curl, text->curc, text->selc, 0);
move= 0;
}
mrk= txt_find_marker_region(text, text->sell, text->selc-1, text->sell->len, 0);
if (mrk) {
@@ -2394,8 +2398,12 @@ int txt_replace_char (Text *text, char add)
if (!text->curl) return 0;
/* If text is selected or we're at the end of the line just use txt_add_char */
if (text->curc==text->curl->len || text->sell!=text->curl || text->selc!=text->curc || add=='\n') {
return txt_add_char(text, add);
if (text->curc==text->curl->len || txt_has_sel(text) || add=='\n') {
TextMarker *mrk;
int i= txt_add_char(text, add);
mrk= txt_find_marker(text, text->curl, text->curc, 0);
if (mrk && mrk->end==text->curc) mrk->end--;
return i;
}
del= text->curl->line[text->curc];

View File

@@ -2462,6 +2462,9 @@ static short do_markers(SpaceText *st, char ascii, unsigned short evnt, short va
if (!text || text->id.lib || text->curl != text->sell) return 0;
marker= txt_find_marker(text, text->sell, text->selc, 0);
if (marker && (marker->start > text->curc || marker->end < text->curc))
marker= NULL;
if (!marker) {
/* Find the next temporary marker */
if (evnt==TABKEY) {
@@ -2498,9 +2501,10 @@ static short do_markers(SpaceText *st, char ascii, unsigned short evnt, short va
c= text->curc-marker->start;
s= text->selc-marker->start;
if (s<0 || s>marker->end-marker->start) return 0;
mrk= txt_next_marker(text, marker);
while (mrk) {
nxt=txt_next_marker(text, mrk); /* mrk may become invalid */
txt_move_to(text, mrk->lineno, mrk->start+c, 0);
if (s!=c) txt_move_to(text, mrk->lineno, mrk->start+s, 1);
if (st->overwrite) {
@@ -2512,8 +2516,8 @@ static short do_markers(SpaceText *st, char ascii, unsigned short evnt, short va
}
}
if (mrk==marker) break;
mrk=txt_next_marker(text, mrk);
if (mrk==marker || mrk==nxt) break;
mrk=nxt;
}
swallow= 1;
draw= 1;
@@ -2533,7 +2537,7 @@ static short do_markers(SpaceText *st, char ascii, unsigned short evnt, short va
if (s!=c) txt_move_to(text, mrk->lineno, mrk->start+s, 1);
txt_backspace_char(text);
if (st->showsyntax) txt_format_line(st, text->curl, 1);
if (mrk==marker) break;
if (mrk==marker || mrk==nxt) break;
mrk= nxt;
}
swallow= 1;
@@ -2553,7 +2557,7 @@ static short do_markers(SpaceText *st, char ascii, unsigned short evnt, short va
if (s!=c) txt_move_to(text, mrk->lineno, mrk->start+s, 1);
txt_delete_char(text);
if (st->showsyntax) txt_format_line(st, text->curl, 1);
if (mrk==marker) break;
if (mrk==marker || mrk==nxt) break;
mrk= nxt;
}
swallow= 1;