diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/inputwidget.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c index 2c1c3165..b695b5c9 100644 --- a/src/ui/inputwidget.c +++ b/src/ui/inputwidget.c | |||
@@ -1225,30 +1225,25 @@ static void contentsWereChanged_InputWidget_(iInputWidget *d) { | |||
1225 | 1225 | ||
1226 | static void deleteIndexRange_InputWidget_(iInputWidget *d, iRanges deleted) { | 1226 | static void deleteIndexRange_InputWidget_(iInputWidget *d, iRanges deleted) { |
1227 | size_t firstModified = iInvalidPos; | 1227 | size_t firstModified = iInvalidPos; |
1228 | for (size_t i = 0; i < size_Array(&d->lines); i++) { | 1228 | for (int i = size_Array(&d->lines) - 1; i >= 0; i--) { |
1229 | iInputLine *line = at_Array(&d->lines, i); | 1229 | iInputLine *line = at_Array(&d->lines, i); |
1230 | if (line->range.end < deleted.start) { | 1230 | if (line->range.end <= deleted.start) { |
1231 | continue; | ||
1232 | } | ||
1233 | if (line->range.start >= deleted.end) { | ||
1234 | break; | 1231 | break; |
1235 | } | 1232 | } |
1236 | if (firstModified == iInvalidPos) { | 1233 | if (line->range.start >= deleted.end) { |
1237 | firstModified = i; | 1234 | continue; |
1238 | } | 1235 | } |
1236 | firstModified = i; | ||
1239 | if (line->range.start >= deleted.start && line->range.end <= deleted.end) { | 1237 | if (line->range.start >= deleted.start && line->range.end <= deleted.end) { |
1240 | /* Delete the entire line. */ | 1238 | clear_String(&line->text); |
1241 | deinit_InputLine(line); | ||
1242 | remove_Array(&d->lines, i--); | ||
1243 | continue; | ||
1244 | } | 1239 | } |
1245 | else if (deleted.start > line->range.start && deleted.end >= line->range.end) { | 1240 | else if (deleted.start > line->range.start && deleted.end >= line->range.end) { |
1246 | truncate_Block(&line->text.chars, deleted.start - line->range.start); | 1241 | truncate_Block(&line->text.chars, deleted.start - line->range.start); |
1247 | } | 1242 | } |
1248 | else if (deleted.start <= line->range.start && deleted.end < line->range.end) { | 1243 | else if (deleted.start <= line->range.start && deleted.end <= line->range.end) { |
1249 | remove_Block(&line->text.chars, 0, deleted.end - line->range.start); | 1244 | remove_Block(&line->text.chars, 0, deleted.end - line->range.start); |
1250 | } | 1245 | } |
1251 | else if (deleted.start > line->range.start && deleted.end < line->range.end) { | 1246 | else if (deleted.start > line->range.start && deleted.end <= line->range.end) { |
1252 | remove_Block(&line->text.chars, deleted.start - line->range.start, size_Range(&deleted)); | 1247 | remove_Block(&line->text.chars, deleted.start - line->range.start, size_Range(&deleted)); |
1253 | } | 1248 | } |
1254 | else { | 1249 | else { |
@@ -1497,6 +1492,10 @@ static void lineTextWasChanged_InputWidget_(iInputWidget *d, iInputLine *line) { | |||
1497 | textOfLinesWasChanged_InputWidget_(d, (iRangei){ y, y + 1 }); | 1492 | textOfLinesWasChanged_InputWidget_(d, (iRangei){ y, y + 1 }); |
1498 | } | 1493 | } |
1499 | 1494 | ||
1495 | static iBool isArrowUpDownConsumed_InputWidget_(const iInputWidget *d) { | ||
1496 | return d->maxWrapLines > 1; | ||
1497 | } | ||
1498 | |||
1500 | static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) { | 1499 | static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) { |
1501 | iWidget *w = as_Widget(d); | 1500 | iWidget *w = as_Widget(d); |
1502 | if (isCommand_Widget(w, ev, "focus.gained")) { | 1501 | if (isCommand_Widget(w, ev, "focus.gained")) { |
@@ -1854,6 +1853,9 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) { | |||
1854 | refresh_Widget(d); | 1853 | refresh_Widget(d); |
1855 | return iTrue; | 1854 | return iTrue; |
1856 | } | 1855 | } |
1856 | if (isArrowUpDownConsumed_InputWidget_(d)) { | ||
1857 | return iTrue; | ||
1858 | } | ||
1857 | /* For moving to lookup from url entry. */ | 1859 | /* For moving to lookup from url entry. */ |
1858 | return processEvent_Widget(as_Widget(d), ev); | 1860 | return processEvent_Widget(as_Widget(d), ev); |
1859 | case SDLK_PAGEUP: | 1861 | case SDLK_PAGEUP: |