diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-12-15 18:56:31 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-12-15 18:56:31 +0200 |
commit | 01c298520d7b6d9ad268d59a6d2a0b99c5cded78 (patch) | |
tree | 915d2736e4420e2cc93975ee91d04eb82d1ad367 /src/ui | |
parent | f8dac44a38ee4dc6472f5d01f66ca9cd7ac1adec (diff) |
Preferences: Option for cursor blinking
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/inputwidget.c | 24 | ||||
-rw-r--r-- | src/ui/util.c | 9 |
2 files changed, 22 insertions, 11 deletions
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c index 49cc0a1e..b910f905 100644 --- a/src/ui/inputwidget.c +++ b/src/ui/inputwidget.c | |||
@@ -588,7 +588,7 @@ static void updateVisible_InputWidget_(iInputWidget *d) { | |||
588 | } | 588 | } |
589 | d->visWrapLines.start += delta; | 589 | d->visWrapLines.start += delta; |
590 | d->visWrapLines.end += delta; | 590 | d->visWrapLines.end += delta; |
591 | iAssert(contains_Range(&d->visWrapLines, cursorY)); | 591 | // iAssert(contains_Range(&d->visWrapLines, cursorY)); |
592 | if (!isFocused_Widget(d) && d->maxWrapLines == 1) { | 592 | if (!isFocused_Widget(d) && d->maxWrapLines == 1) { |
593 | d->visWrapLines.start = 0; | 593 | d->visWrapLines.start = 0; |
594 | d->visWrapLines.end = 1; | 594 | d->visWrapLines.end = 1; |
@@ -711,7 +711,10 @@ static uint32_t cursorTimer_(uint32_t interval, void *w) { | |||
711 | return interval; | 711 | return interval; |
712 | } | 712 | } |
713 | 713 | ||
714 | static void startOrStopCursorTimer_InputWidget_(iInputWidget *d, iBool doStart) { | 714 | static void startOrStopCursorTimer_InputWidget_(iInputWidget *d, int doStart) { |
715 | if (!prefs_App()->blinkingCursor && doStart == 1) { | ||
716 | doStart = iFalse; | ||
717 | } | ||
715 | if (doStart && !d->timer) { | 718 | if (doStart && !d->timer) { |
716 | d->timer = SDL_AddTimer(refreshInterval_InputWidget_, cursorTimer_, d); | 719 | d->timer = SDL_AddTimer(refreshInterval_InputWidget_, cursorTimer_, d); |
717 | } | 720 | } |
@@ -2167,6 +2170,12 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) { | |||
2167 | return iFalse; | 2170 | return iFalse; |
2168 | } | 2171 | } |
2169 | #if !LAGRANGE_USE_SYSTEM_TEXT_INPUT | 2172 | #if !LAGRANGE_USE_SYSTEM_TEXT_INPUT |
2173 | else if (isCommand_UserEvent(ev, "prefs.blink.changed")) { | ||
2174 | if (isEditing_InputWidget_(d) && arg_Command(command_UserEvent(ev))) { | ||
2175 | startOrStopCursorTimer_InputWidget_(d, 2); | ||
2176 | } | ||
2177 | return iFalse; | ||
2178 | } | ||
2170 | else if (isEditing_InputWidget_(d) && (isCommand_UserEvent(ev, "window.focus.lost") || | 2179 | else if (isEditing_InputWidget_(d) && (isCommand_UserEvent(ev, "window.focus.lost") || |
2171 | isCommand_UserEvent(ev, "window.focus.gained"))) { | 2180 | isCommand_UserEvent(ev, "window.focus.gained"))) { |
2172 | startOrStopCursorTimer_InputWidget_(d, isCommand_UserEvent(ev, "window.focus.gained")); | 2181 | startOrStopCursorTimer_InputWidget_(d, isCommand_UserEvent(ev, "window.focus.gained")); |
@@ -2613,10 +2622,10 @@ static void draw_InputWidget_(const iInputWidget *d) { | |||
2613 | return; | 2622 | return; |
2614 | } | 2623 | } |
2615 | const iRect contentBounds = contentBounds_InputWidget_(d); | 2624 | const iRect contentBounds = contentBounds_InputWidget_(d); |
2616 | iInt2 drawPos = topLeft_Rect(contentBounds); | 2625 | iInt2 drawPos = topLeft_Rect(contentBounds); |
2617 | const int fg = isHint ? uiAnnotation_ColorId | 2626 | const int fg = isHint ? uiAnnotation_ColorId |
2618 | : isFocused /*&& !isEmpty_Array(&d->lines)*/ ? uiInputTextFocused_ColorId | 2627 | : isFocused ? uiInputTextFocused_ColorId |
2619 | : uiInputText_ColorId; | 2628 | : uiInputText_ColorId; |
2620 | #if !LAGRANGE_USE_SYSTEM_TEXT_INPUT | 2629 | #if !LAGRANGE_USE_SYSTEM_TEXT_INPUT |
2621 | setClip_Paint(&p, | 2630 | setClip_Paint(&p, |
2622 | adjusted_Rect(bounds, | 2631 | adjusted_Rect(bounds, |
@@ -2685,7 +2694,8 @@ static void draw_InputWidget_(const iInputWidget *d) { | |||
2685 | wrapText.context = NULL; | 2694 | wrapText.context = NULL; |
2686 | } | 2695 | } |
2687 | /* Draw the insertion point. */ | 2696 | /* Draw the insertion point. */ |
2688 | if (isFocused && d->cursorVis && contains_Range(&visLines, d->cursor.y) && | 2697 | if (isFocused && (d->cursorVis || !prefs_App()->blinkingCursor) && |
2698 | contains_Range(&visLines, d->cursor.y) && | ||
2689 | (deviceType_App() == desktop_AppDeviceType || isEmpty_Range(&d->mark))) { | 2699 | (deviceType_App() == desktop_AppDeviceType || isEmpty_Range(&d->mark))) { |
2690 | iInt2 curSize; | 2700 | iInt2 curSize; |
2691 | iRangecc cursorChar = iNullRange; | 2701 | iRangecc cursorChar = iNullRange; |
diff --git a/src/ui/util.c b/src/ui/util.c index db24b6fc..a46c7f80 100644 --- a/src/ui/util.c +++ b/src/ui/util.c | |||
@@ -2629,9 +2629,8 @@ iWidget *makePreferences_Widget(void) { | |||
2629 | } | 2629 | } |
2630 | /* User Interface. */ { | 2630 | /* User Interface. */ { |
2631 | appendTwoColumnTabPage_Widget(tabs, "${heading.prefs.interface}", '2', &headings, &values); | 2631 | appendTwoColumnTabPage_Widget(tabs, "${heading.prefs.interface}", '2', &headings, &values); |
2632 | #if defined (LAGRANGE_ENABLE_CUSTOM_FRAME) | 2632 | addDialogToggle_(headings, values, "${prefs.animate}", "prefs.animate"); |
2633 | addDialogToggle_(headings, values, "${prefs.customframe}", "prefs.customframe"); | 2633 | addDialogToggle_(headings, values, "${prefs.blink}", "prefs.blink"); |
2634 | #endif | ||
2635 | addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.returnkey}"))); | 2634 | addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.returnkey}"))); |
2636 | /* Return key behaviors. */ { | 2635 | /* Return key behaviors. */ { |
2637 | iLabelWidget *returnKey = makeMenuButton_LabelWidget( | 2636 | iLabelWidget *returnKey = makeMenuButton_LabelWidget( |
@@ -2645,7 +2644,9 @@ iWidget *makePreferences_Widget(void) { | |||
2645 | setId_Widget(addChildFlags_Widget(values, iClob(returnKey), alignLeft_WidgetFlag), | 2644 | setId_Widget(addChildFlags_Widget(values, iClob(returnKey), alignLeft_WidgetFlag), |
2646 | "prefs.returnkey"); | 2645 | "prefs.returnkey"); |
2647 | } | 2646 | } |
2648 | addDialogToggle_(headings, values, "${prefs.animate}", "prefs.animate"); | 2647 | #if defined (LAGRANGE_ENABLE_CUSTOM_FRAME) |
2648 | addDialogToggle_(headings, values, "${prefs.customframe}", "prefs.customframe"); | ||
2649 | #endif | ||
2649 | makeTwoColumnHeading_("${heading.prefs.scrolling}", headings, values); | 2650 | makeTwoColumnHeading_("${heading.prefs.scrolling}", headings, values); |
2650 | addDialogToggle_(headings, values, "${prefs.smoothscroll}", "prefs.smoothscroll"); | 2651 | addDialogToggle_(headings, values, "${prefs.smoothscroll}", "prefs.smoothscroll"); |
2651 | /* Scroll speeds. */ { | 2652 | /* Scroll speeds. */ { |