[haiku-commits] haiku: hrev45156 - src/kits/interface headers/os/interface

  • From: zharik@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 14 Jan 2013 21:12:56 +0100 (CET)

hrev45156 adds 1 changeset to branch 'master'
old head: 075d3e60f4e6fd3882b113f8fa19cd6f5c88e40d
new head: dc871e324d59c1cd691fdedca8807d11e5b959d0
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=dc871e3+%5E075d3e6

----------------------------------------------------------------------------

dc871e3: TextView:Cmd/Ctrl-Home/End Shift-selection support
  
  Fixes #6859
  
  Signed-off-by: Siarzhuk Zharski <zharik@xxxxxx>

                                [ Przemysław Buczkowski <przemub@xxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev45156
Commit:      dc871e324d59c1cd691fdedca8807d11e5b959d0
URL:         http://cgit.haiku-os.org/haiku/commit/?id=dc871e3
Author:      Przemysław Buczkowski <przemub@xxxxxxxx>
Date:        Mon Jan 14 19:18:15 2013 UTC
Committer:   Siarzhuk Zharski <zharik@xxxxxx>
Commit-Date: Mon Jan 14 20:10:21 2013 UTC

Ticket:      https://dev.haiku-os.org/ticket/6859

----------------------------------------------------------------------------

2 files changed, 41 insertions(+), 2 deletions(-)
headers/os/interface/TextView.h |  2 ++
src/kits/interface/TextView.cpp | 41 +++++++++++++++++++++++++++++++++++--

----------------------------------------------------------------------------

diff --git a/headers/os/interface/TextView.h b/headers/os/interface/TextView.h
index cf23a1a..4e746fd 100644
--- a/headers/os/interface/TextView.h
+++ b/headers/os/interface/TextView.h
@@ -455,6 +455,8 @@ private:
                        int32                           fLastClickOffset;
                        bool                            
fInstalledNavigateWordwiseShortcuts;
                        bool                            
fInstalledNavigateToTopOrBottomShortcuts;
+                       bool                            
fInstalledSelectWordwiseShortcuts;
+                       bool                            
fInstalledSelectToTopOrBottomShortcuts;
 
                        uint32                          _reserved[6];
 };
diff --git a/src/kits/interface/TextView.cpp b/src/kits/interface/TextView.cpp
index 3d97a63..47d665e 100644
--- a/src/kits/interface/TextView.cpp
+++ b/src/kits/interface/TextView.cpp
@@ -3343,6 +3343,8 @@ BTextView::_InitObject(BRect textRect, const BFont 
*initialFont,
 
        fInstalledNavigateWordwiseShortcuts = false;
        fInstalledNavigateToTopOrBottomShortcuts = false;
+       fInstalledSelectWordwiseShortcuts = false;
+       fInstalledSelectToTopOrBottomShortcuts = false;
 
        // We put these here instead of in the constructor initializer list
        // to have less code duplication, and a single place where to do changes
@@ -3619,6 +3621,7 @@ BTextView::_HandlePageKey(uint32 inPageKey, bool 
commandKeyDown)
                currentMessage->FindInt32("modifiers", &mods);
 
        bool shiftDown = mods & B_SHIFT_KEY;
+       bool controlDown = mods & B_CONTROL_KEY;
        STELine* line = NULL;
        int32 selStart = fSelStart;
        int32 selEnd = fSelEnd;
@@ -3631,7 +3634,7 @@ BTextView::_HandlePageKey(uint32 inPageKey, bool 
commandKeyDown)
                                break;
                        }
 
-                       if (commandKeyDown) {
+                       if (commandKeyDown || controlDown) {
                                _ScrollTo(0, 0);
                                fCaretOffset = 0;
                        } else {
@@ -3664,7 +3667,7 @@ BTextView::_HandlePageKey(uint32 inPageKey, bool 
commandKeyDown)
                                break;
                        }
 
-                       if (commandKeyDown) {
+                       if (commandKeyDown || controlDown) {
                                _ScrollTo(0, fTextRect.bottom + 
fLayoutData->bottomInset);
                                fCaretOffset = fText->Length();
                        } else {
@@ -5178,6 +5181,18 @@ BTextView::_Activate()
                                new BMessage(NAVIGATE_TO_NEXT_WORD), this);
                        fInstalledNavigateWordwiseShortcuts = true;
                }
+               if (!Window()->HasShortcut(B_LEFT_ARROW, B_COMMAND_KEY | 
B_SHIFT_KEY)
+               && !Window()->HasShortcut(B_RIGHT_ARROW, B_COMMAND_KEY | 
B_SHIFT_KEY)) {
+                       BMessage* message = new 
BMessage(NAVIGATE_TO_PREVIOUS_WORD);
+                       message->AddInt32("modifiers", B_SHIFT_KEY);
+                       Window()->AddShortcut(B_LEFT_ARROW, B_COMMAND_KEY | 
B_SHIFT_KEY,
+                               message, this);
+                       message = new BMessage(NAVIGATE_TO_NEXT_WORD);
+                       message->AddInt32("modifiers", B_SHIFT_KEY);
+                       Window()->AddShortcut(B_RIGHT_ARROW, B_COMMAND_KEY | 
B_SHIFT_KEY,
+                               message, this);
+                       fInstalledSelectWordwiseShortcuts = true;
+               }
                if (!Window()->HasShortcut(B_HOME, B_COMMAND_KEY)
                && !Window()->HasShortcut(B_END, B_COMMAND_KEY)) {
                        Window()->AddShortcut(B_HOME, B_COMMAND_KEY,
@@ -5186,6 +5201,18 @@ BTextView::_Activate()
                                new BMessage(NAVIGATE_TO_BOTTOM), this);
                        fInstalledNavigateToTopOrBottomShortcuts = true;
                }
+               if (!Window()->HasShortcut(B_HOME, B_COMMAND_KEY | B_SHIFT_KEY)
+               && !Window()->HasShortcut(B_END, B_COMMAND_KEY | B_SHIFT_KEY)) {
+                       BMessage* message = new BMessage(NAVIGATE_TO_TOP);
+                       message->AddInt32("modifiers", B_SHIFT_KEY);
+                       Window()->AddShortcut(B_HOME, B_COMMAND_KEY | 
B_SHIFT_KEY,
+                               message, this);
+                       message = new BMessage(NAVIGATE_TO_BOTTOM);
+                       message->AddInt32("modifiers", B_SHIFT_KEY);
+                       Window()->AddShortcut(B_END, B_COMMAND_KEY | 
B_SHIFT_KEY,
+                               message, this);
+                       fInstalledSelectToTopOrBottomShortcuts = true;
+               }
        }
 }
 
@@ -5212,11 +5239,21 @@ BTextView::_Deactivate()
                        Window()->RemoveShortcut(B_RIGHT_ARROW, B_COMMAND_KEY);
                        fInstalledNavigateWordwiseShortcuts = false;
                }
+               if (fInstalledSelectWordwiseShortcuts) {
+                       Window()->RemoveShortcut(B_LEFT_ARROW, B_COMMAND_KEY | 
B_SHIFT_KEY);
+                       Window()->RemoveShortcut(B_RIGHT_ARROW, B_COMMAND_KEY | 
B_SHIFT_KEY);
+                       fInstalledSelectWordwiseShortcuts = false;
+               }
                if (fInstalledNavigateToTopOrBottomShortcuts) {
                        Window()->RemoveShortcut(B_HOME, B_COMMAND_KEY);
                        Window()->RemoveShortcut(B_END, B_COMMAND_KEY);
                        fInstalledNavigateToTopOrBottomShortcuts = false;
                }
+               if (fInstalledSelectToTopOrBottomShortcuts) {
+                       Window()->RemoveShortcut(B_HOME, B_COMMAND_KEY | 
B_SHIFT_KEY);
+                       Window()->RemoveShortcut(B_END, B_COMMAND_KEY | 
B_SHIFT_KEY);
+                       fInstalledSelectToTopOrBottomShortcuts = false;
+               }
        }
 }
 


Other related posts: