include/vcl/vclmedit.hxx | 3 +++ include/vcl/weld.hxx | 10 ++++++++++ vcl/source/app/salvtables.cxx | 12 ++++++++++++ vcl/source/edit/vclmedit.cxx | 16 ++++++++++++++++ vcl/unx/gtk3/gtk3gtkinst.cxx | 18 ++++++++++++++++++ 5 files changed, 59 insertions(+)
New commits: commit 253d4c15e73b0a22320dbebb4bdf17f8fdb03649 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Wed Jul 8 17:08:51 2020 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Wed Jul 8 22:06:05 2020 +0200 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 <caol...@redhat.com> diff --git a/include/vcl/vclmedit.hxx b/include/vcl/vclmedit.hxx index 307d218a5846..caec816bd4b3 100644 --- a/include/vcl/vclmedit.hxx +++ b/include/vcl/vclmedit.hxx @@ -134,6 +134,9 @@ public: virtual OUString GetSelected() const override; OUString GetSelected( LineEnd aSeparator ) const; + bool CanUp() const; + bool CanDown() const; + virtual void Cut() override; virtual void Copy() override; virtual void Paste() override; diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index 7649accf8b2d..73f27cd9a517 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -2041,6 +2041,16 @@ public: m_aCursorPositionHdl = rLink; } + // returns true if pressing up would move the cursor + // doesn't matter if that move is to a previous line or to the start of the + // current line just so long as the cursor would move + virtual bool can_move_cursor_with_up() const = 0; + + // returns true if pressing down would move the cursor + // doesn't matter if that move is to a next line or to the end of the + // current line just so long as the cursor would move + virtual bool can_move_cursor_with_down() const = 0; + virtual void cut_clipboard() = 0; virtual void copy_clipboard() = 0; virtual void paste_clipboard() = 0; 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), _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits