[prev in list] [next in list] [prev in thread] [next in thread] 

List:       konsole-devel
Subject:    [Konsole-devel] Disable BiDi rendering in konsole4
From:       Diego Iastrubni <elcuco () kde ! org>
Date:       2008-03-14 19:14:45
Message-ID: 200803142114.45536.elcuco () kde ! org
[Download RAW message or body]

Hello all,

One feature which is missing from konsole4 (comparing to konsole3) is the 
rendering of BiDi. In konsole3 BiDi was disabled by default and it can be 
enabled from the options dialog, or pressing alt+control+b.

In QPainter4, there is no option for this, but it may be hacked using &LRO;
+text (I will open a task in Trolltech and ask for such method in Qt4.5). 
Meanwhile, I have a patch here which enables/disables this feature (note that 
there was some code left in konsole, some variables already defined which 
deal with BiDi).

I still am missing the keyboard shortcut to enable/disable this on the current 
view/profile, and I was hopping someone would give me a hint about this.

The patch is attached, and I can commit if no one objects.

- diego

["konsole4-bidi.patch" (text/x-diff)]

Index: src/Profile.cpp
===================================================================
--- src/Profile.cpp	(revision 785310)
+++ src/Profile.cpp	(working copy)
@@ -97,6 +97,7 @@
 	, { BlinkingTextEnabled , "BlinkingTextEnabled" , TERMINAL_GROUP , QVariant::Bool }
     , { FlowControlEnabled , "FlowControlEnabled" , TERMINAL_GROUP , QVariant::Bool \
                }
     , { AllowProgramsToResizeWindow , "AllowProgramsToResizeWindow" , TERMINAL_GROUP \
, QVariant::Bool } +    , { BidiRenderingEnabled , "BidiRenderingEnabled" , \
                TERMINAL_GROUP , QVariant::Bool }
     , { BlinkingCursorEnabled , "BlinkingCursorEnabled" , TERMINAL_GROUP , \
QVariant::Bool }  
 	// Cursor 
Index: src/EditProfileDialog.cpp
===================================================================
--- src/EditProfileDialog.cpp	(revision 785310)
+++ src/EditProfileDialog.cpp	(working copy)
@@ -922,6 +922,8 @@
                                  SLOT(toggleResizeWindow(bool)) },
                                { _ui->enableBlinkingCursorButton , \
Profile::BlinkingCursorEnabled ,  SLOT(toggleBlinkingCursor(bool)) },
+                               { _ui->enableBidiRenderingButton , \
Profile::BidiRenderingEnabled , +                                 \
SLOT(togglebidiRendering(bool)) },  { 0 , 0 , 0 }
                              };
     setupCombo( options , profile );
@@ -988,6 +990,10 @@
 {
     _tempProfile->setProperty(Profile::CursorShape,index);
 }
+void EditProfileDialog::togglebidiRendering(bool enable)
+{
+    _tempProfile->setProperty(Profile::BidiRenderingEnabled,enable);
+}
 void EditProfileDialog::toggleBlinkingCursor(bool enable)
 {
     _tempProfile->setProperty(Profile::BlinkingCursorEnabled,enable);
Index: src/ViewManager.cpp
===================================================================
--- src/ViewManager.cpp	(revision 785310)
+++ src/ViewManager.cpp	(working copy)
@@ -715,6 +715,9 @@
     bool blinkingCursor = info->property<bool>(Profile::BlinkingCursorEnabled);
     view->setBlinkingCursor(blinkingCursor);  
 
+    bool bidiEnabled = info->property<bool>(Profile::BidiRenderingEnabled);
+    view->setBidiEnabled(bidiEnabled);
+
     // cursor shape
     int cursorShape = info->property<int>(Profile::CursorShape);
 
Index: src/Profile.h
===================================================================
--- src/Profile.h	(revision 785310)
+++ src/Profile.h	(working copy)
@@ -143,7 +143,8 @@
          * terminal displays using this profile.
          */
         ScrollBarPosition,  
-
+        /** (bool) Specifies whether the terminal will enable Bidirectional text \
display */ +        BidiRenderingEnabled,
         /** (bool) Specifies whether text in terminal displays is allowed to blink. \
*/  BlinkingTextEnabled,       
         /** (bool) Specifies whether the flow control keys ( typically Ctrl+S , \
                Ctrl+Q )
Index: src/TerminalDisplay.h
===================================================================
--- src/TerminalDisplay.h	(revision 785310)
+++ src/TerminalDisplay.h	(working copy)
@@ -372,7 +372,14 @@
      */
     void setTerminalSizeStartup(bool on) { _terminalSizeStartup=on; }
 
+    /**
+     * Sets the status of the BiDi rendering inside the terminal display.
+     * Defaults to disabled.
+     */
     void setBidiEnabled(bool set) { _bidiEnabled=set; }
+    /**
+     * Returns the status of the BiDi rendering in this widget.
+     */
     bool isBidiEnabled() { return _bidiEnabled; }
 
     /**
Index: src/EditProfileDialog.h
===================================================================
--- src/EditProfileDialog.h	(revision 785310)
+++ src/EditProfileDialog.h	(working copy)
@@ -154,6 +154,7 @@
     void toggleBlinkingText(bool);
     void toggleFlowControl(bool);
     void toggleResizeWindow(bool);
+    void togglebidiRendering(bool);
     void toggleBlinkingCursor(bool);
 
     void setCursorShape(int);
Index: src/TerminalDisplay.cpp
===================================================================
--- src/TerminalDisplay.cpp	(revision 785310)
+++ src/TerminalDisplay.cpp	(working copy)
@@ -653,16 +653,19 @@
 
     // draw text
     if ( isLineCharString(text) )
-	  	drawLineCharString(painter,rect.x(),rect.y(),text,style);
+        drawLineCharString(painter,rect.x(),rect.y(),text,style);
     else
-	{
-		// the drawText(rect,flags,string) overload is used here with null flags
-		// instead of drawText(rect,string) because the (rect,string) overload causes 
-		// the application's default layout direction to be used instead of 
-		// the widget-specific layout direction, which should always be
-		// Qt::LeftToRight for this widget
-        painter.drawText(rect,0,text);
-	}
+    {
+        // the drawText(rect,flags,string) overload is used here with null flags
+        // instead of drawText(rect,string) because the (rect,string) overload \
causes  +        // the application's default layout direction to be used instead of 
+        // the widget-specific layout direction, which should always be
+        // Qt::LeftToRight for this widget
+        if (_bidiEnabled)
+            painter.drawText(rect,0,text);
+        else
+            painter.drawText(rect,0,QChar(0x202D)+text);
+    }
 }
 
 void TerminalDisplay::drawTextFragment(QPainter& painter , 
Index: src/EditProfileDialog.ui
===================================================================
--- src/EditProfileDialog.ui	(revision 785310)
+++ src/EditProfileDialog.ui	(working copy)
@@ -5,8 +5,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>441</width>
-    <height>499</height>
+    <width>462</width>
+    <height>532</height>
    </rect>
   </property>
   <layout class="QHBoxLayout" >
@@ -32,8 +32,8 @@
        <rect>
         <x>0</x>
         <y>0</y>
-        <width>437</width>
-        <height>472</height>
+        <width>450</width>
+        <height>492</height>
        </rect>
       </property>
       <attribute name="title" >
@@ -238,8 +238,8 @@
        <rect>
         <x>0</x>
         <y>0</y>
-        <width>437</width>
-        <height>472</height>
+        <width>450</width>
+        <height>492</height>
        </rect>
       </property>
       <attribute name="title" >
@@ -381,8 +381,8 @@
        <rect>
         <x>0</x>
         <y>0</y>
-        <width>437</width>
-        <height>472</height>
+        <width>450</width>
+        <height>492</height>
        </rect>
       </property>
       <attribute name="title" >
@@ -599,8 +599,8 @@
        <rect>
         <x>0</x>
         <y>0</y>
-        <width>437</width>
-        <height>472</height>
+        <width>450</width>
+        <height>492</height>
        </rect>
       </property>
       <attribute name="title" >
@@ -777,8 +777,8 @@
        <rect>
         <x>0</x>
         <y>0</y>
-        <width>437</width>
-        <height>472</height>
+        <width>450</width>
+        <height>492</height>
        </rect>
       </property>
       <attribute name="title" >
@@ -867,8 +867,8 @@
        <rect>
         <x>0</x>
         <y>0</y>
-        <width>437</width>
-        <height>472</height>
+        <width>450</width>
+        <height>492</height>
        </rect>
       </property>
       <attribute name="title" >
@@ -883,55 +883,75 @@
          <property name="flat" >
           <bool>true</bool>
          </property>
-         <layout class="QVBoxLayout" >
+         <layout class="QVBoxLayout" name="verticalLayout_2" >
           <item>
-           <widget class="QCheckBox" name="enableBlinkingTextButton" >
-            <property name="sizePolicy" >
-             <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
-              <horstretch>0</horstretch>
-              <verstretch>0</verstretch>
-             </sizepolicy>
-            </property>
-            <property name="toolTip" >
-             <string>Allow terminal programs to create blinking sections of \
                text</string>
-            </property>
-            <property name="text" >
-             <string>Allow blinking text</string>
-            </property>
-           </widget>
+           <layout class="QVBoxLayout" name="verticalLayout" >
+            <item>
+             <widget class="QCheckBox" name="enableBlinkingTextButton" >
+              <property name="sizePolicy" >
+               <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
+                <horstretch>0</horstretch>
+                <verstretch>0</verstretch>
+               </sizepolicy>
+              </property>
+              <property name="toolTip" >
+               <string>Allow terminal programs to create blinking sections of \
text</string> +              </property>
+              <property name="text" >
+               <string>Allow blinking text</string>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <widget class="QCheckBox" name="enableFlowControlButton" >
+              <property name="sizePolicy" >
+               <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
+                <horstretch>0</horstretch>
+                <verstretch>0</verstretch>
+               </sizepolicy>
+              </property>
+              <property name="toolTip" >
+               <string>Allow the output to be suspended by pressing Ctrl+S</string>
+              </property>
+              <property name="text" >
+               <string>Enable flow control using Ctrl+S , Ctrl+Q</string>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <widget class="QCheckBox" name="enableResizeWindowButton" >
+              <property name="sizePolicy" >
+               <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
+                <horstretch>0</horstretch>
+                <verstretch>0</verstretch>
+               </sizepolicy>
+              </property>
+              <property name="toolTip" >
+               <string>Allow terminal programs to resize the window</string>
+              </property>
+              <property name="text" >
+               <string>Allow programs to resize terminal window</string>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <widget class="QCheckBox" name="enableBidiRenderingButton" >
+              <property name="sizePolicy" >
+               <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
+                <horstretch>0</horstretch>
+                <verstretch>0</verstretch>
+               </sizepolicy>
+              </property>
+              <property name="toolTip" >
+               <string>Enable BiDirectional display on terminals (valid for Arabic, \
Farsi or Hebrew only)</string> +              </property>
+              <property name="text" >
+               <string>Enable BiDi rendering </string>
+              </property>
+             </widget>
+            </item>
+           </layout>
           </item>
-          <item>
-           <widget class="QCheckBox" name="enableFlowControlButton" >
-            <property name="sizePolicy" >
-             <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
-              <horstretch>0</horstretch>
-              <verstretch>0</verstretch>
-             </sizepolicy>
-            </property>
-            <property name="toolTip" >
-             <string>Allow the output to be suspended by pressing Ctrl+S</string>
-            </property>
-            <property name="text" >
-             <string>Enable flow control using Ctrl+S , Ctrl+Q</string>
-            </property>
-           </widget>
-          </item>
-          <item>
-           <widget class="QCheckBox" name="enableResizeWindowButton" >
-            <property name="sizePolicy" >
-             <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
-              <horstretch>0</horstretch>
-              <verstretch>0</verstretch>
-             </sizepolicy>
-            </property>
-            <property name="toolTip" >
-             <string>Allow terminal programs to resize the window</string>
-            </property>
-            <property name="text" >
-             <string>Allow programs to resize terminal window</string>
-            </property>
-           </widget>
-          </item>
          </layout>
         </widget>
        </item>



_______________________________________________
konsole-devel mailing list
konsole-devel@kde.org
https://mail.kde.org/mailman/listinfo/konsole-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic