diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-07-08 17:08:51 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-07-08 22:06:05 +0200 |
commit | 253d4c15e73b0a22320dbebb4bdf17f8fdb03649 (patch) | |
tree | a96a542924a3d02c5607fa05fd7156e3bf017a67 /vcl | |
parent | 94f4bdb910a9db49016ea23cd0086f70a1468363 (diff) |
query if the cursor can be moved up or down
Change-Id: I47c09ff5f76c873cf30e608a134f90b42040a0c3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98387
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/app/salvtables.cxx | 12 | ||||
-rw-r--r-- | vcl/source/edit/vclmedit.cxx | 16 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 18 |
3 files changed, 46 insertions, 0 deletions
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 893a7f4f0b49..e30bbd057c71 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -5500,6 +5500,18 @@ public: weld::TextView::connect_cursor_position(rLink); } + virtual bool can_move_cursor_with_up() const override + { + bool bNoSelection = !m_xTextView->GetSelection(); + return !bNoSelection || m_xTextView->CanUp(); + } + + virtual bool can_move_cursor_with_down() const override + { + bool bNoSelection = !m_xTextView->GetSelection(); + return !bNoSelection || m_xTextView->CanDown(); + } + virtual void cut_clipboard() override { m_xTextView->Cut(); diff --git a/vcl/source/edit/vclmedit.cxx b/vcl/source/edit/vclmedit.cxx index 021ef7658837..fe459ba59a0d 100644 --- a/vcl/source/edit/vclmedit.cxx +++ b/vcl/source/edit/vclmedit.cxx @@ -1515,6 +1515,22 @@ void VclMultiLineEdit::EnableCursor( bool bEnable ) GetTextView()->EnableCursor( bEnable ); } +bool VclMultiLineEdit::CanUp() const +{ + TextView* pTextView = GetTextView(); + const TextSelection& rTextSelection = pTextView->GetSelection(); + TextPaM aPaM(rTextSelection.GetEnd()); + return aPaM != pTextView->CursorUp(aPaM); +} + +bool VclMultiLineEdit::CanDown() const +{ + TextView* pTextView = GetTextView(); + const TextSelection& rTextSelection = pTextView->GetSelection(); + TextPaM aPaM(rTextSelection.GetEnd()); + return aPaM != pTextView->CursorDown(aPaM); +} + TextWindow* VclMultiLineEdit::GetTextWindow() { return pImpVclMEdit->GetTextWindow(); diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 5ba41f9e028a..1cba75f751e2 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -12553,6 +12553,24 @@ public: g_signal_handler_unblock(m_pVAdjustment, m_nVAdjustChangedSignalId); } + // in gtk, 'up' when on the first line, will jump to the start of the line + // if not there already + virtual bool can_move_cursor_with_up() const override + { + GtkTextIter start, end; + gtk_text_buffer_get_selection_bounds(m_pTextBuffer, &start, &end); + return !gtk_text_iter_equal(&start, &end) || !gtk_text_iter_is_start(&start); + } + + // in gtk, 'down' when on the first line, will jump to the end of the line + // if not there already + virtual bool can_move_cursor_with_down() const override + { + GtkTextIter start, end; + gtk_text_buffer_get_selection_bounds(m_pTextBuffer, &start, &end); + return !gtk_text_iter_equal(&start, &end) || !gtk_text_iter_is_end(&end); + } + virtual void cut_clipboard() override { GtkClipboard *pClipboard = gtk_widget_get_clipboard(GTK_WIDGET(m_pTextView), |