[haiku-commits] haiku: hrev53544 - src/apps/terminal

  • From: Stephan Aßmus <superstippi@xxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 16 Oct 2019 03:27:35 -0400 (EDT)

hrev53544 adds 1 changeset to branch 'master'
old head: d8779e44ee61b6435c33fcbb6bcd23e859aa6593
new head: e3c74f400eb110f300b7e6063123fdd027b94d93
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=e3c74f400eb1+%5Ed8779e44ee61

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

e3c74f400eb1: Terminal: Add support for extended mouse coordinates
  
  Fixes #11949
  
  Change-Id: I779d1a9af2e3208ba3c055692de5e62b6a7b72fc
  Reviewed-on: https://review.haiku-os.org/c/haiku/+/1919
  Reviewed-by: Stephan Aßmus <superstippi@xxxxxx>

                               [ Lukasz Towarek <lukasz.towarek@xxxxxxxxx> ]

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

Revision:    hrev53544
Commit:      e3c74f400eb110f300b7e6063123fdd027b94d93
URL:         https://git.haiku-os.org/haiku/commit/?id=e3c74f400eb1
Author:      Lukasz Towarek <lukasz.towarek@xxxxxxxxx>
Date:        Tue Oct 15 20:42:22 2019 UTC
Committer:   Stephan Aßmus <superstippi@xxxxxx>
Commit-Date: Wed Oct 16 07:27:31 2019 UTC

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

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

6 files changed, 101 insertions(+), 38 deletions(-)
src/apps/terminal/TermConst.h        |   4 +-
src/apps/terminal/TermParse.cpp      |   8 +++
src/apps/terminal/TermView.cpp       | 114 +++++++++++++++++++++----------
src/apps/terminal/TermView.h         |   1 +
src/apps/terminal/TerminalBuffer.cpp |  11 +++
src/apps/terminal/TerminalBuffer.h   |   1 +

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

diff --git a/src/apps/terminal/TermConst.h b/src/apps/terminal/TermConst.h
index b4e01a5902..aa726cfbfa 100644
--- a/src/apps/terminal/TermConst.h
+++ b/src/apps/terminal/TermConst.h
@@ -177,9 +177,9 @@ enum {
 #define TAB_WIDTH 8
 
 #define MIN_COLS 10
-#define MAX_COLS 256
+#define MAX_COLS 999
 #define MIN_ROWS 10
-#define MAX_ROWS 256
+#define MAX_ROWS 999
 
 // Insert mode flag
 #define MODE_OVER 0
diff --git a/src/apps/terminal/TermParse.cpp b/src/apps/terminal/TermParse.cpp
index aaec4e1bd1..0a2b71ae9d 100644
--- a/src/apps/terminal/TermParse.cpp
+++ b/src/apps/terminal/TermParse.cpp
@@ -1395,6 +1395,10 @@ TermParse::_DecPrivateModeSet(int value)
                        // Use All Motion Mouse Tracking
                        fBuffer->ReportAnyMouseEvent(true);
                        break;
+               case 1006:
+                       // Enable extended mouse coordinates with SGR scheme
+                       fBuffer->EnableExtendedMouseCoordinates(true);
+                       break;
                case 1034:
                        // Interpret "meta" key, sets eighth bit.
                        fBuffer->EnableInterpretMetaKey(true);
@@ -1470,6 +1474,10 @@ TermParse::_DecPrivateModeReset(int value)
                        // Disable All Motion Mouse Tracking.
                        fBuffer->ReportAnyMouseEvent(false);
                        break;
+               case 1006:
+                       // Disable extended mouse coordinates with SGR scheme
+                       fBuffer->EnableExtendedMouseCoordinates(false);
+                       break;
                case 1034:
                        // Don't interpret "meta" key.
                        fBuffer->EnableInterpretMetaKey(false);
diff --git a/src/apps/terminal/TermView.cpp b/src/apps/terminal/TermView.cpp
index c574fc9c5f..14c7758e80 100644
--- a/src/apps/terminal/TermView.cpp
+++ b/src/apps/terminal/TermView.cpp
@@ -174,7 +174,8 @@ TermView::TermView(BRect frame, const ShellParameters& 
shellParameters,
        fReportX10MouseEvent(false),
        fReportNormalMouseEvent(false),
        fReportButtonMouseEvent(false),
-       fReportAnyMouseEvent(false)
+       fReportAnyMouseEvent(false),
+       fEnableExtendedMouseCoordinates(false)
 {
        status_t status = _InitObject(shellParameters);
        if (status != B_OK)
@@ -197,7 +198,8 @@ TermView::TermView(int rows, int columns,
        fReportX10MouseEvent(false),
        fReportNormalMouseEvent(false),
        fReportButtonMouseEvent(false),
-       fReportAnyMouseEvent(false)
+       fReportAnyMouseEvent(false),
+       fEnableExtendedMouseCoordinates(false)
 {
        status_t status = _InitObject(shellParameters);
        if (status != B_OK)
@@ -230,7 +232,8 @@ TermView::TermView(BMessage* archive)
        fReportX10MouseEvent(false),
        fReportNormalMouseEvent(false),
        fReportButtonMouseEvent(false),
-       fReportAnyMouseEvent(false)
+       fReportAnyMouseEvent(false),
+       fEnableExtendedMouseCoordinates(false)
 {
        BRect frame = Bounds();
 
@@ -317,6 +320,7 @@ TermView::_InitObject(const ShellParameters& 
shellParameters)
        fReportNormalMouseEvent = false;
        fReportButtonMouseEvent = false;
        fReportAnyMouseEvent = false;
+       fEnableExtendedMouseCoordinates = false;
        fMouseClipboard = be_clipboard;
        fDefaultState = new(std::nothrow) DefaultState(this);
        fSelectState = new(std::nothrow) SelectState(this);
@@ -1846,18 +1850,21 @@ TermView::MessageReceived(BMessage *msg)
                }
                case MSG_REPORT_MOUSE_EVENT:
                {
-                       bool report;
-                       if (msg->FindBool("reportX10MouseEvent", &report) == 
B_OK)
-                               fReportX10MouseEvent = report;
+                       bool value;
+                       if (msg->FindBool("reportX10MouseEvent", &value) == 
B_OK)
+                               fReportX10MouseEvent = value;
 
-                       if (msg->FindBool("reportNormalMouseEvent", &report) == 
B_OK)
-                               fReportNormalMouseEvent = report;
+                       if (msg->FindBool("reportNormalMouseEvent", &value) == 
B_OK)
+                               fReportNormalMouseEvent = value;
 
-                       if (msg->FindBool("reportButtonMouseEvent", &report) == 
B_OK)
-                               fReportButtonMouseEvent = report;
+                       if (msg->FindBool("reportButtonMouseEvent", &value) == 
B_OK)
+                               fReportButtonMouseEvent = value;
 
-                       if (msg->FindBool("reportAnyMouseEvent", &report) == 
B_OK)
-                               fReportAnyMouseEvent = report;
+                       if (msg->FindBool("reportAnyMouseEvent", &value) == 
B_OK)
+                               fReportAnyMouseEvent = value;
+
+                       if (msg->FindBool("enableExtendedMouseCoordinates", 
&value) == B_OK)
+                               fEnableExtendedMouseCoordinates = value;
                        break;
                }
                case MSG_REMOVE_RESIZE_VIEW_IF_NEEDED:
@@ -2407,30 +2414,65 @@ void
 TermView::_SendMouseEvent(int32 buttons, int32 mode, int32 x, int32 y,
        bool motion)
 {
-       char xtermButtons;
-       if (buttons == B_PRIMARY_MOUSE_BUTTON)
-               xtermButtons = 32 + 0;
-       else if (buttons == B_SECONDARY_MOUSE_BUTTON)
-               xtermButtons = 32 + 1;
-       else if (buttons == B_TERTIARY_MOUSE_BUTTON)
-               xtermButtons = 32 + 2;
-       else
-               xtermButtons = 32 + 3;
-
-       if (motion)
-               xtermButtons += 32;
-
-       char xtermX = x + 1 + 32;
-       char xtermY = y + 1 + 32;
-
-       char destBuffer[6];
-       destBuffer[0] = '\033';
-       destBuffer[1] = '[';
-       destBuffer[2] = 'M';
-       destBuffer[3] = xtermButtons;
-       destBuffer[4] = xtermX;
-       destBuffer[5] = xtermY;
-       fShell->Write(destBuffer, 6);
+       if (!fEnableExtendedMouseCoordinates) {
+               char xtermButtons;
+               if (buttons == B_PRIMARY_MOUSE_BUTTON)
+                       xtermButtons = 32 + 0;
+               else if (buttons == B_SECONDARY_MOUSE_BUTTON)
+                       xtermButtons = 32 + 1;
+               else if (buttons == B_TERTIARY_MOUSE_BUTTON)
+                       xtermButtons = 32 + 2;
+               else
+                       xtermButtons = 32 + 3;
+
+               if (motion)
+                       xtermButtons += 32;
+
+               char xtermX = x + 1 + 32;
+               char xtermY = y + 1 + 32;
+
+               char destBuffer[6];
+               destBuffer[0] = '\033';
+               destBuffer[1] = '[';
+               destBuffer[2] = 'M';
+               destBuffer[3] = xtermButtons;
+               destBuffer[4] = xtermX;
+               destBuffer[5] = xtermY;
+               fShell->Write(destBuffer, 6);
+       } else {
+               char xtermButtons;
+               if (buttons == B_PRIMARY_MOUSE_BUTTON)
+                       xtermButtons = 0;
+               else if (buttons == B_SECONDARY_MOUSE_BUTTON)
+                       xtermButtons = 1;
+               else if (buttons == B_TERTIARY_MOUSE_BUTTON)
+                       xtermButtons = 2;
+               else
+                       xtermButtons = 3;
+
+               if (motion)
+                       xtermButtons += 32;
+
+               int16 xtermX = x + 1;
+               int16 xtermY = y + 1;
+
+               char destBuffer[13];
+               destBuffer[0] = '\033';
+               destBuffer[1] = '[';
+               destBuffer[2] = '<';
+               destBuffer[3] = xtermButtons + '0';
+               destBuffer[4] = ';';
+               destBuffer[5] = xtermX / 100 % 10 + '0';
+               destBuffer[6] = xtermX / 10 % 10 + '0';
+               destBuffer[7] = xtermX % 10 + '0';
+               destBuffer[8] = ';';
+               destBuffer[9] = xtermY / 100 % 10 + '0';
+               destBuffer[10] = xtermY / 10 % 10 + '0';
+               destBuffer[11] = xtermY % 10 + '0';
+               // No support for button press/release
+               destBuffer[12] = 'M';
+               fShell->Write(destBuffer, 13);
+       }
 }
 
 
diff --git a/src/apps/terminal/TermView.h b/src/apps/terminal/TermView.h
index f23241028d..f1e8a1b914 100644
--- a/src/apps/terminal/TermView.h
+++ b/src/apps/terminal/TermView.h
@@ -359,6 +359,7 @@ private:
                        bool                            fReportNormalMouseEvent;
                        bool                            fReportButtonMouseEvent;
                        bool                            fReportAnyMouseEvent;
+                       bool                            
fEnableExtendedMouseCoordinates;
                        BClipboard*                     fMouseClipboard;
 
                        // states
diff --git a/src/apps/terminal/TerminalBuffer.cpp 
b/src/apps/terminal/TerminalBuffer.cpp
index e3fd5fb731..83e70ecbcc 100644
--- a/src/apps/terminal/TerminalBuffer.cpp
+++ b/src/apps/terminal/TerminalBuffer.cpp
@@ -157,6 +157,17 @@ TerminalBuffer::ReportAnyMouseEvent(bool 
reportAnyMouseEvent)
 }
 
 
+void
+TerminalBuffer::EnableExtendedMouseCoordinates(bool enable)
+{
+       if (fListenerValid) {
+               BMessage message(MSG_REPORT_MOUSE_EVENT);
+               message.AddBool("enableExtendedMouseCoordinates", enable);
+               fListener.SendMessage(&message);
+       }
+}
+
+
 void
 TerminalBuffer::SetEncoding(int encoding)
 {
diff --git a/src/apps/terminal/TerminalBuffer.h 
b/src/apps/terminal/TerminalBuffer.h
index e4d198765e..6d5c4ae1d0 100644
--- a/src/apps/terminal/TerminalBuffer.h
+++ b/src/apps/terminal/TerminalBuffer.h
@@ -60,6 +60,7 @@ public:
                        void                            
ReportNormalMouseEvent(bool report);
                        void                            
ReportButtonMouseEvent(bool report);
                        void                            
ReportAnyMouseEvent(bool report);
+                       void                            
EnableExtendedMouseCoordinates(bool enable);
 
 protected:
        virtual void                            NotifyListener();


Other related posts:

  • » [haiku-commits] haiku: hrev53544 - src/apps/terminal - Stephan Aßmus