diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gmdocument.c | 8 | ||||
-rw-r--r-- | src/macos.m | 4 | ||||
-rw-r--r-- | src/ui/documentwidget.c | 35 |
3 files changed, 31 insertions, 16 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c index c271ad94..508047a6 100644 --- a/src/gmdocument.c +++ b/src/gmdocument.c | |||
@@ -2065,14 +2065,20 @@ iRangecc findLoc_GmRun(const iGmRun *d, iInt2 pos) { | |||
2065 | if (pos.y < top_Rect(d->bounds)) { | 2065 | if (pos.y < top_Rect(d->bounds)) { |
2066 | return (iRangecc){ d->text.start, d->text.start }; | 2066 | return (iRangecc){ d->text.start, d->text.start }; |
2067 | } | 2067 | } |
2068 | if (pos.y > bottom_Rect(d->bounds)) { | ||
2069 | return (iRangecc){ d->text.end, d->text.end }; | ||
2070 | } | ||
2068 | const int x = pos.x - left_Rect(d->bounds); | 2071 | const int x = pos.x - left_Rect(d->bounds); |
2069 | if (x <= 0) { | 2072 | if (x <= 0) { |
2070 | return (iRangecc){ d->text.start, d->text.start }; | 2073 | return (iRangecc){ d->text.start, d->text.start }; |
2071 | } | 2074 | } |
2075 | if (x > d->bounds.size.x) { | ||
2076 | return (iRangecc){ d->text.end, d->text.end }; | ||
2077 | } | ||
2072 | iRangecc loc; | 2078 | iRangecc loc; |
2073 | tryAdvanceNoWrap_Text(d->font, d->text, x, &loc.start); | 2079 | tryAdvanceNoWrap_Text(d->font, d->text, x, &loc.start); |
2074 | loc.end = loc.start; | 2080 | loc.end = loc.start; |
2075 | if (!contains_Range(&d->text, loc.start)) { | 2081 | if (!contains_Range(&d->text, loc.start) && loc.start != d->text.end) { |
2076 | return iNullRange; /* it's some other text */ | 2082 | return iNullRange; /* it's some other text */ |
2077 | } | 2083 | } |
2078 | iChar ch; | 2084 | iChar ch; |
diff --git a/src/macos.m b/src/macos.m index d737e9e8..784a8612 100644 --- a/src/macos.m +++ b/src/macos.m | |||
@@ -570,7 +570,11 @@ static NSMenuItem *makeMenuItems_(NSMenu *menu, MenuCommands *commands, const iM | |||
570 | deinit_String(&itemTitle); | 570 | deinit_String(&itemTitle); |
571 | [item setTarget:commands]; | 571 | [item setTarget:commands]; |
572 | if (isChecked) { | 572 | if (isChecked) { |
573 | #if defined (__MAC_10_13) | ||
573 | [item setState:NSControlStateValueOn]; | 574 | [item setState:NSControlStateValueOn]; |
575 | #else | ||
576 | [item setState:NSOnState]; | ||
577 | #endif | ||
574 | selectedItem = item; | 578 | selectedItem = item; |
575 | } | 579 | } |
576 | [item setEnabled:!isDisabled]; | 580 | [item setEnabled:!isDisabled]; |
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 */ |