diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gmdocument.c | 4 | ||||
-rw-r--r-- | src/macos.m | 4 | ||||
-rw-r--r-- | src/ui/documentwidget.c | 5 | ||||
-rw-r--r-- | src/ui/keys.h | 2 | ||||
-rw-r--r-- | src/ui/labelwidget.c | 25 | ||||
-rw-r--r-- | src/ui/util.c | 7 |
6 files changed, 34 insertions, 13 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c index 874a117e..007311d2 100644 --- a/src/gmdocument.c +++ b/src/gmdocument.c | |||
@@ -537,7 +537,7 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
537 | } | 537 | } |
538 | } | 538 | } |
539 | /* Folded blocks are represented by a single run with the alt text. */ | 539 | /* Folded blocks are represented by a single run with the alt text. */ |
540 | if (isPreformat) { | 540 | if (isPreformat && d->format != plainText_GmDocumentFormat) { |
541 | const iGmPreMeta *meta = constAt_Array(&d->preMeta, preId - 1); | 541 | const iGmPreMeta *meta = constAt_Array(&d->preMeta, preId - 1); |
542 | if (meta->flags & folded_GmPreMetaFlag) { | 542 | if (meta->flags & folded_GmPreMetaFlag) { |
543 | const iBool isBlank = isEmpty_Range(&meta->altText); | 543 | const iBool isBlank = isEmpty_Range(&meta->altText); |
@@ -669,7 +669,7 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
669 | type == quote_GmLineType ? 4 : 0); | 669 | type == quote_GmLineType ? 4 : 0); |
670 | const iBool isWordWrapped = | 670 | const iBool isWordWrapped = |
671 | (d->format == plainText_GmDocumentFormat ? prefs->plainTextWrap : !isPreformat); | 671 | (d->format == plainText_GmDocumentFormat ? prefs->plainTextWrap : !isPreformat); |
672 | if (isPreformat) { | 672 | if (isPreformat && d->format != plainText_GmDocumentFormat) { |
673 | /* Remember the top left coordinates of the block (first line of block). */ | 673 | /* Remember the top left coordinates of the block (first line of block). */ |
674 | iGmPreMeta *meta = at_Array(&d->preMeta, preId - 1); | 674 | iGmPreMeta *meta = at_Array(&d->preMeta, preId - 1); |
675 | if (~meta->flags & topLeft_GmPreMetaFlag) { | 675 | if (~meta->flags & topLeft_GmPreMetaFlag) { |
diff --git a/src/macos.m b/src/macos.m index 0dcc3ef5..61507b6f 100644 --- a/src/macos.m +++ b/src/macos.m | |||
@@ -497,7 +497,7 @@ void insertMenuItems_MacOS(const char *menuLabel, int atIndex, const iMenuItem * | |||
497 | [myDel setCommand:[NSString stringWithUTF8String:items[i].command] forMenuItem:item]; | 497 | [myDel setCommand:[NSString stringWithUTF8String:items[i].command] forMenuItem:item]; |
498 | /* Bindings may have a different key. */ | 498 | /* Bindings may have a different key. */ |
499 | const iBinding *bind = findCommand_Keys(items[i].command); | 499 | const iBinding *bind = findCommand_Keys(items[i].command); |
500 | if (bind) { | 500 | if (bind && bind->id < builtIn_BindingId) { |
501 | key = bind->key; | 501 | key = bind->key; |
502 | kmods = bind->mods; | 502 | kmods = bind->mods; |
503 | } | 503 | } |
@@ -533,7 +533,7 @@ void handleCommand_MacOS(const char *cmd) { | |||
533 | if (command) { | 533 | if (command) { |
534 | const iBinding *bind = findCommand_Keys( | 534 | const iBinding *bind = findCommand_Keys( |
535 | [command cStringUsingEncoding:NSUTF8StringEncoding]); | 535 | [command cStringUsingEncoding:NSUTF8StringEncoding]); |
536 | if (bind) { | 536 | if (bind && bind->id < builtIn_BindingId) { |
537 | setShortcut_NSMenuItem_(menuItem, bind->key, bind->mods); | 537 | setShortcut_NSMenuItem_(menuItem, bind->key, bind->mods); |
538 | } | 538 | } |
539 | } | 539 | } |
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 891d8588..d338cf04 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -562,7 +562,8 @@ static void updateHover_DocumentWidget_(iDocumentWidget *d, iInt2 mouse) { | |||
562 | animate_DocumentWidget_(d); | 562 | animate_DocumentWidget_(d); |
563 | refresh_Widget(w); | 563 | refresh_Widget(w); |
564 | } | 564 | } |
565 | else if (d->hoverPre && targetValue_Anim(&d->altTextOpacity) < 0.5f) { | 565 | else if (d->hoverPre && targetValue_Anim(&d->altTextOpacity) < 0.5f && |
566 | ~d->flags & noHoverWhileScrolling_DocumentWidgetFlag) { | ||
566 | setValue_Anim(&d->altTextOpacity, 1.0f, 0); | 567 | setValue_Anim(&d->altTextOpacity, 1.0f, 0); |
567 | refresh_Widget(w); | 568 | refresh_Widget(w); |
568 | } | 569 | } |
@@ -3477,7 +3478,7 @@ static void draw_DocumentWidget_(const iDocumentWidget *d) { | |||
3477 | const iGmPreMeta *meta = preMeta_GmDocument(d->doc, d->hoverAltPre->preId); | 3478 | const iGmPreMeta *meta = preMeta_GmDocument(d->doc, d->hoverAltPre->preId); |
3478 | if (meta->flags & topLeft_GmPreMetaFlag && ~meta->flags & decoration_GmRunFlag && | 3479 | if (meta->flags & topLeft_GmPreMetaFlag && ~meta->flags & decoration_GmRunFlag && |
3479 | !isEmpty_Range(&meta->altText)) { | 3480 | !isEmpty_Range(&meta->altText)) { |
3480 | const int margin = 2 * gap_UI; | 3481 | const int margin = 3 * gap_UI / 2; |
3481 | const int altFont = uiLabel_FontId; | 3482 | const int altFont = uiLabel_FontId; |
3482 | const int wrap = docBounds.size.x - 2 * margin; | 3483 | const int wrap = docBounds.size.x - 2 * margin; |
3483 | iInt2 pos = addY_I2(add_I2(docBounds.pos, meta->pixelRect.pos), | 3484 | iInt2 pos = addY_I2(add_I2(docBounds.pos, meta->pixelRect.pos), |
diff --git a/src/ui/keys.h b/src/ui/keys.h index 90e33b7c..4cbca3b7 100644 --- a/src/ui/keys.h +++ b/src/ui/keys.h | |||
@@ -56,6 +56,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |||
56 | # define subscribeToPage_KeyModifier SDLK_d, KMOD_SHIFT | KMOD_PRIMARY | 56 | # define subscribeToPage_KeyModifier SDLK_d, KMOD_SHIFT | KMOD_PRIMARY |
57 | #endif | 57 | #endif |
58 | 58 | ||
59 | #define builtIn_BindingId 1000 /* not user-configurable */ | ||
60 | |||
59 | iDeclareType(Binding) | 61 | iDeclareType(Binding) |
60 | 62 | ||
61 | struct Impl_Binding { | 63 | struct Impl_Binding { |
diff --git a/src/ui/labelwidget.c b/src/ui/labelwidget.c index 1805525c..d16ef69d 100644 --- a/src/ui/labelwidget.c +++ b/src/ui/labelwidget.c | |||
@@ -172,6 +172,10 @@ static void getColors_LabelWidget_(const iLabelWidget *d, int *bg, int *fg, int | |||
172 | *frame2 = uiEmbossSelected2_ColorId; | 172 | *frame2 = uiEmbossSelected2_ColorId; |
173 | } | 173 | } |
174 | } | 174 | } |
175 | int colorEscape = none_ColorId; | ||
176 | if (startsWith_String(&d->label, "\r")) { | ||
177 | colorEscape = cstr_String(&d->label)[1] - asciiBase_ColorEscape; /* TODO: can be two bytes long */ | ||
178 | } | ||
175 | if (isHover_Widget(w)) { | 179 | if (isHover_Widget(w)) { |
176 | if (isFrameless) { | 180 | if (isFrameless) { |
177 | *bg = uiBackgroundFramelessHover_ColorId; | 181 | *bg = uiBackgroundFramelessHover_ColorId; |
@@ -179,14 +183,14 @@ static void getColors_LabelWidget_(const iLabelWidget *d, int *bg, int *fg, int | |||
179 | } | 183 | } |
180 | else { | 184 | else { |
181 | /* Frames matching color escaped text. */ | 185 | /* Frames matching color escaped text. */ |
182 | if (startsWith_String(&d->label, "\r")) { | 186 | if (colorEscape != none_ColorId) { |
183 | if (isDark_ColorTheme(colorTheme_App())) { | 187 | if (isDark_ColorTheme(colorTheme_App())) { |
184 | *frame1 = cstr_String(&d->label)[1] - asciiBase_ColorEscape; | 188 | *frame1 = colorEscape; |
185 | *frame2 = darker_Color(*frame1); | 189 | *frame2 = darker_Color(*frame1); |
186 | } | 190 | } |
187 | else { | 191 | else { |
188 | *bg = *frame1 = *frame2 = cstr_String(&d->label)[1] - asciiBase_ColorEscape; | 192 | *bg = *frame1 = *frame2 = colorEscape; |
189 | *fg = uiBackground_ColorId | permanent_ColorId; | 193 | *fg = uiText_ColorId | permanent_ColorId; |
190 | } | 194 | } |
191 | } | 195 | } |
192 | else if (isSel) { | 196 | else if (isSel) { |
@@ -204,9 +208,14 @@ static void getColors_LabelWidget_(const iLabelWidget *d, int *bg, int *fg, int | |||
204 | *bg = uiBackgroundPressed_ColorId | permanent_ColorId; | 208 | *bg = uiBackgroundPressed_ColorId | permanent_ColorId; |
205 | if (isButton) { | 209 | if (isButton) { |
206 | *frame1 = uiEmbossPressed1_ColorId; | 210 | *frame1 = uiEmbossPressed1_ColorId; |
207 | *frame2 = uiEmbossPressed2_ColorId; | 211 | *frame2 = colorEscape != none_ColorId ? colorEscape : uiEmbossPressed2_ColorId; |
212 | } | ||
213 | if (colorEscape == none_ColorId || colorEscape == uiTextAction_ColorId) { | ||
214 | *fg = uiTextPressed_ColorId | permanent_ColorId; | ||
215 | } | ||
216 | else { | ||
217 | *fg = isDark_ColorTheme(colorTheme_App()) ? white_ColorId : black_ColorId; | ||
208 | } | 218 | } |
209 | *fg = uiTextPressed_ColorId | permanent_ColorId; | ||
210 | } | 219 | } |
211 | if (d->forceFg >= 0) { | 220 | if (d->forceFg >= 0) { |
212 | *fg = d->forceFg; | 221 | *fg = d->forceFg; |
@@ -288,7 +297,9 @@ static void draw_LabelWidget_(const iLabelWidget *d) { | |||
288 | add_I2(topRight_Rect(bounds), | 297 | add_I2(topRight_Rect(bounds), |
289 | addX_I2(negX_I2(padding_(flags)), | 298 | addX_I2(negX_I2(padding_(flags)), |
290 | deviceType_App() == tablet_AppDeviceType ? gap_UI : 0)), | 299 | deviceType_App() == tablet_AppDeviceType ? gap_UI : 0)), |
291 | flags & pressed_WidgetFlag ? fg : uiTextShortcut_ColorId, | 300 | flags & pressed_WidgetFlag ? fg |
301 | : isCaution ? uiTextCaution_ColorId | ||
302 | : uiTextShortcut_ColorId, | ||
292 | right_Alignment, | 303 | right_Alignment, |
293 | cstr_String(&str)); | 304 | cstr_String(&str)); |
294 | deinit_String(&str); | 305 | deinit_String(&str); |
diff --git a/src/ui/util.c b/src/ui/util.c index 19fba3a4..08a04105 100644 --- a/src/ui/util.c +++ b/src/ui/util.c | |||
@@ -96,6 +96,9 @@ void toString_Sym(int key, int kmods, iString *str) { | |||
96 | if (key == 0x20) { | 96 | if (key == 0x20) { |
97 | appendCStr_String(str, "Space"); | 97 | appendCStr_String(str, "Space"); |
98 | } | 98 | } |
99 | else if (key == SDLK_ESCAPE) { | ||
100 | appendCStr_String(str, "Esc"); | ||
101 | } | ||
99 | else if (key == SDLK_LEFT) { | 102 | else if (key == SDLK_LEFT) { |
100 | appendChar_String(str, 0x2190); | 103 | appendChar_String(str, 0x2190); |
101 | } | 104 | } |
@@ -117,6 +120,9 @@ void toString_Sym(int key, int kmods, iString *str) { | |||
117 | else if (key == SDLK_DELETE) { | 120 | else if (key == SDLK_DELETE) { |
118 | appendChar_String(str, 0x2326); /* Erase to the Right */ | 121 | appendChar_String(str, 0x2326); /* Erase to the Right */ |
119 | } | 122 | } |
123 | else if (key == SDLK_RETURN) { | ||
124 | appendChar_String(str, 0x21a9); /* Leftwards arrow with a hook */ | ||
125 | } | ||
120 | else { | 126 | else { |
121 | appendCStr_String(str, SDL_GetKeyName(key)); | 127 | appendCStr_String(str, SDL_GetKeyName(key)); |
122 | } | 128 | } |
@@ -1631,6 +1637,7 @@ iWidget *makeDialogButtons_Widget(const iMenuItem *actions, size_t numActions) { | |||
1631 | } | 1637 | } |
1632 | iLabelWidget *button = | 1638 | iLabelWidget *button = |
1633 | addChild_Widget(div, iClob(newKeyMods_LabelWidget(label, key, kmods, cmd))); | 1639 | addChild_Widget(div, iClob(newKeyMods_LabelWidget(label, key, kmods, cmd))); |
1640 | setFlags_Widget(as_Widget(button), alignLeft_WidgetFlag | drawKey_WidgetFlag, isDefault); | ||
1634 | setFont_LabelWidget(button, isDefault ? fonts[1] : fonts[0]); | 1641 | setFont_LabelWidget(button, isDefault ? fonts[1] : fonts[0]); |
1635 | } | 1642 | } |
1636 | return div; | 1643 | return div; |