diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/documentwidget.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 44db3e5b..ee669c1a 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -3419,7 +3419,7 @@ static void beginMarkingSelection_DocumentWidget_(iDocumentWidget *d, iInt2 pos) | |||
3419 | invalidateWideRunsWithNonzeroOffset_DocumentWidget_(d); | 3419 | invalidateWideRunsWithNonzeroOffset_DocumentWidget_(d); |
3420 | resetWideRuns_DocumentWidget_(d); /* Selections don't support horizontal scrolling. */ | 3420 | resetWideRuns_DocumentWidget_(d); /* Selections don't support horizontal scrolling. */ |
3421 | iChangeFlags(d->flags, selecting_DocumentWidgetFlag, iTrue); | 3421 | iChangeFlags(d->flags, selecting_DocumentWidgetFlag, iTrue); |
3422 | d->selectMark = sourceLoc_DocumentWidget_(d, pos); | 3422 | d->initialSelectMark = d->selectMark = sourceLoc_DocumentWidget_(d, pos); |
3423 | refresh_Widget(as_Widget(d)); | 3423 | refresh_Widget(as_Widget(d)); |
3424 | } | 3424 | } |
3425 | 3425 | ||
@@ -3843,7 +3843,13 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e | |||
3843 | } | 3843 | } |
3844 | } | 3844 | } |
3845 | else { | 3845 | else { |
3846 | d->selectMark.end = (d->selectMark.end > d->selectMark.start ? loc.end : loc.start); | 3846 | d->selectMark.end = loc.end;// (d->selectMark.end > d->selectMark.start ? loc.end : loc.start); |
3847 | if (loc.start < d->initialSelectMark.start) { | ||
3848 | d->selectMark.end = loc.start; | ||
3849 | } | ||
3850 | if (isEmpty_Range(&d->selectMark)) { | ||
3851 | d->selectMark = d->initialSelectMark; | ||
3852 | } | ||
3847 | } | 3853 | } |
3848 | } | 3854 | } |
3849 | iAssert((!d->selectMark.start && !d->selectMark.end) || | 3855 | iAssert((!d->selectMark.start && !d->selectMark.end) || |
@@ -3861,13 +3867,13 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e | |||
3861 | d->initialSelectMark.start = | 3867 | d->initialSelectMark.start = |
3862 | d->initialSelectMark.end = d->selectMark.start; | 3868 | d->initialSelectMark.end = d->selectMark.start; |
3863 | } | 3869 | } |
3864 | if (!isEmpty_Range(&d->initialSelectMark)) { | 3870 | } |
3865 | if (d->selectMark.end > d->selectMark.start) { | 3871 | if (d->initialSelectMark.start) { |
3866 | d->selectMark.start = d->initialSelectMark.start; | 3872 | if (d->selectMark.end > d->selectMark.start) { |
3867 | } | 3873 | d->selectMark.start = d->initialSelectMark.start; |
3868 | else if (d->selectMark.end < d->selectMark.start) { | 3874 | } |
3869 | d->selectMark.start = d->initialSelectMark.end; | 3875 | else if (d->selectMark.end < d->selectMark.start) { |
3870 | } | 3876 | d->selectMark.start = d->initialSelectMark.end; |
3871 | } | 3877 | } |
3872 | } | 3878 | } |
3873 | // printf("mark %zu ... %zu\n", d->selectMark.start - cstr_String(source_GmDocument(d->doc)), | 3879 | // printf("mark %zu ... %zu\n", d->selectMark.start - cstr_String(source_GmDocument(d->doc)), |
@@ -4072,12 +4078,11 @@ static void fillRange_DrawContext_(iDrawContext *d, const iGmRun *run, enum iCol | |||
4072 | } | 4078 | } |
4073 | int w = width_Rect(run->visBounds) - x; | 4079 | int w = width_Rect(run->visBounds) - x; |
4074 | if (contains_Range(&run->text, mark.end) || mark.end < run->text.start) { | 4080 | if (contains_Range(&run->text, mark.end) || mark.end < run->text.start) { |
4075 | w = measureRange_Text( | 4081 | iRangecc mk = !*isInside ? mark |
4076 | run->font, | 4082 | : (iRangecc){ run->text.start, iMax(run->text.start, mark.end) }; |
4077 | !*isInside ? mark | 4083 | mk.start = iMax(mk.start, run->text.start); |
4078 | : (iRangecc){ run->text.start, iMax(run->text.start, mark.end) }) | 4084 | w = measureRange_Text(run->font, mk).advance.x; |
4079 | .advance.x; | 4085 | *isInside = iFalse; |
4080 | *isInside = iFalse; | ||
4081 | } | 4086 | } |
4082 | else { | 4087 | else { |
4083 | *isInside = iTrue; /* at least until the next run */ | 4088 | *isInside = iTrue; /* at least until the next run */ |