70 lines
2.3 KiB
Diff
70 lines
2.3 KiB
Diff
commit 92e4041efb6165505a8729968648392d7b5ff459
|
|
Author: Gabriel Ebner <gebner@gebner.org>
|
|
Date: Sun Aug 16 19:47:52 2020 +0200
|
|
|
|
Allow the user to disable cursor blinking.
|
|
|
|
This uses the same setting which is also used by the built-in text entry
|
|
widget.
|
|
|
|
diff --git a/src/gui/TextEditor.cpp b/src/gui/TextEditor.cpp
|
|
index 0750ad0e..807786cf 100644
|
|
--- a/src/gui/TextEditor.cpp
|
|
+++ b/src/gui/TextEditor.cpp
|
|
@@ -37,6 +37,7 @@ TextEditor::TextEditor(XojPageView* gui, GtkWidget* widget, Text* text, bool own
|
|
gtk_text_buffer_place_cursor(this->buffer, &first);
|
|
|
|
GtkSettings* settings = gtk_widget_get_settings(this->widget);
|
|
+ g_object_get(settings, "gtk-cursor-blink", &this->cursorBlink, nullptr);
|
|
g_object_get(settings, "gtk-cursor-blink-time", &this->cursorBlinkTime, nullptr);
|
|
g_object_get(settings, "gtk-cursor-blink-timeout", &this->cursorBlinkTimeout, nullptr);
|
|
|
|
@@ -48,7 +49,12 @@ TextEditor::TextEditor(XojPageView* gui, GtkWidget* widget, Text* text, bool own
|
|
g_signal_connect(this->imContext, "retrieve-surrounding", G_CALLBACK(iMRetrieveSurroundingCallback), this);
|
|
g_signal_connect(this->imContext, "delete-surrounding", G_CALLBACK(imDeleteSurroundingCallback), this);
|
|
|
|
- blinkCallback(this);
|
|
+ if (this->cursorBlink) {
|
|
+ blinkCallback(this);
|
|
+ } else {
|
|
+ this->cursorVisible = true;
|
|
+ }
|
|
+
|
|
}
|
|
|
|
TextEditor::~TextEditor()
|
|
@@ -654,12 +660,15 @@ void TextEditor::moveCursor(GtkMovementStep step, int count, bool extendSelectio
|
|
gtk_widget_error_bell(this->widget);
|
|
}
|
|
|
|
- this->cursorVisible = false;
|
|
- if (this->blinkTimeout)
|
|
- {
|
|
- g_source_remove(this->blinkTimeout);
|
|
- }
|
|
- blinkCallback(this);
|
|
+ if (this->cursorBlink) {
|
|
+ this->cursorVisible = false;
|
|
+ if (this->blinkTimeout) {
|
|
+ g_source_remove(this->blinkTimeout);
|
|
+ }
|
|
+ blinkCallback(this);
|
|
+ } else {
|
|
+ repaintCursor();
|
|
+ }
|
|
}
|
|
|
|
void TextEditor::findPos(GtkTextIter* iter, double xPos, double yPos)
|
|
diff --git a/src/gui/TextEditor.h b/src/gui/TextEditor.h
|
|
index fdeb8b0f..008807b1 100644
|
|
--- a/src/gui/TextEditor.h
|
|
+++ b/src/gui/TextEditor.h
|
|
@@ -108,6 +108,7 @@ private:
|
|
double markPosX = 0;
|
|
double markPosY = 0;
|
|
|
|
+ bool cursorBlink = true;
|
|
int cursorBlinkTime = 0;
|
|
int cursorBlinkTimeout = 0;
|
|
int blinkTimeout = 0; // handler id
|