Esc removes markers in stages. Temporary markers are removed first (if any) then other markers follow.

This commit is contained in:
Ian Thompson
2008-08-16 14:38:08 +00:00
parent d1d1d2b870
commit 310a6e2179
3 changed files with 20 additions and 9 deletions

View File

@@ -102,8 +102,8 @@ void txt_copy_clipboard (struct Text *text);
void txt_paste_clipboard (struct Text *text);
void txt_add_marker (struct Text *text, struct TextLine *line, int start, int end, char clr[4], int flags);
void txt_clear_marker_region (struct Text *text, struct TextLine *line, int start, int end, int flags);
void txt_clear_markers (struct Text *text, int flags);
short txt_clear_marker_region (struct Text *text, struct TextLine *line, int start, int end, int flags);
short txt_clear_markers (struct Text *text, int flags);
struct TextMarker *txt_find_marker (struct Text *text, struct TextLine *line, int curs, int flags);
struct TextMarker *txt_find_marker_region (struct Text *text, struct TextLine *line, int start, int end, int flags);
struct TextMarker *txt_prev_marker (struct Text *text, struct TextMarker *marker);

View File

@@ -2727,9 +2727,10 @@ TextMarker *txt_find_marker_region(Text *text, TextLine *line, int start, int en
/* Clears all markers on the specified line between two points with at least
the specified flags set. If flags is zero, all markers will be cleared */
void txt_clear_marker_region(Text *text, TextLine *line, int start, int end, int flags) {
short txt_clear_marker_region(Text *text, TextLine *line, int start, int end, int flags) {
TextMarker *marker, *next;
int lineno= txt_get_span(text->lines.first, line);
short cleared= 0;
for (marker=text->markers.first; marker; marker=next) {
next= marker->next;
@@ -2739,22 +2740,29 @@ void txt_clear_marker_region(Text *text, TextLine *line, int start, int end, int
else if (marker->lineno > lineno) break;
if ((marker->start==marker->end && start<=marker->start && marker->start<=end) ||
(marker->start<end && marker->end>start))
(marker->start<end && marker->end>start)) {
BLI_freelinkN(&text->markers, marker);
cleared= 1;
}
}
return cleared;
}
/* Clears all markers with at least the specified flags set (useful for
clearing temporary markers) */
void txt_clear_markers(Text *text, int flags) {
short txt_clear_markers(Text *text, int flags) {
TextMarker *marker, *next;
short cleared= 0;
for (marker=text->markers.first; marker; marker=next) {
next= marker->next;
if ((marker->flags & flags) == flags)
if ((marker->flags & flags) == flags) {
BLI_freelinkN(&text->markers, marker);
cleared= 1;
}
}
return cleared;
}
/* Finds the marker at the specified line and cursor position with at least the

View File

@@ -2483,6 +2483,12 @@ static short do_markers(SpaceText *st, char ascii, unsigned short evnt, short va
draw= 1;
swallow= 1;
}
} else if (evnt==ESCKEY) {
if (txt_clear_markers(text, TMARK_TEMP)) swallow= 1;
else if (txt_clear_markers(text, 0)) swallow= 1;
else return 0;
evnt= ascii= val= 0;
draw= 1;
}
if (!swallow) return 0;
}
@@ -3113,9 +3119,6 @@ void winqreadtextspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
do_draw= 1;
pop_space_text(st);
break;
case ESCKEY:
txt_clear_markers(text, TMARK_TEMP);
break;
case BACKSPACEKEY:
if (text && text->id.lib) {
error_libdata();