[Konsole-devel] Re: Patch for konsole

Éric Brunet ebrunet at lps.ens.fr
Mon Jul 1 14:15:01 UTC 2002


On Monday 1 July 2002, Stephan Binner wrote:
> You forgot default.Keytab which MakeDefauls converts to default.keytab.h.

Ok, I forgot this one.
> 
> Your patch changes default behaviour, e.g. Alt-Backspace (delete wordwise
> in Bash). Did you ever try? That's why I wrote you have to change keytables
> to adjust it so behaviour stays the same, e.g. for Alt-Backspace you must
> 
>  -key Backspace      : "\x7f"
>  +key Backspace-Alt  : "\x7f"
>  +key Backspace+Alt  : "\E\x7f"
> 
Ok, I see your point now.

> and this for every key assignment in 5 keytables. Makes them
> unmaintainable.
> 
> Did you raise any objection against adding the same option (with standard
> prepend) as in xterm? Seems to be more understandable concept for the
> user.

No I don't have any serious objection to another configuration option, as
long as it allows everybody to configure konsole as he wishes. However,
It seems to me that the mechanism you propose is contrary to the
principle of least surprise. Someone who gives a specific rule in a
configuration file expects the rule to be exactly followed, and if he
sees that it is not the case, he will conclude that there is a bug
without looking for an improbable configuration option.

I have another proposition: if '+Alt' appears in the configuration line,
don't add an escape to the text given. If '+Alt' does not appear, prepend
an escape. This way:

	key Backspace	: "\x7f"

will work as usual (meta-backspace sends <Escape>\x7f), and

	key I +Alt :	"Hello world"

gives what is expected, that is a "Hello world" without any modification.

And we spare yet another configuration option.

To do that, we need to change KeyTrans::findEntry to tell us if the Alt
modifier was specified or not in the configuration file. As far as I see, this
method is called only once, so we can change it easily.

I propose the following patch:

===============================================================================
--- keytrans.h.orig	Mon Jul  1 15:52:38 2002
+++ keytrans.h	Mon Jul  1 16:07:39 2002
@@ -51,7 +51,8 @@
 
       KeyTrans(const QString& p);
       ~KeyTrans();
-      bool findEntry(int key, int bits, int* cmd, const char** txt, int* len);
+      bool findEntry(int key, int bits, int* cmd, const char** txt, int* len,
+		      bool* metaspecified);
       const QString& hdr()         {if (!m_fileRead) readConfig(); return m_hdr;}
       int numb()                   {return m_numb;}
       const QString& id() { return m_id;}
@@ -62,6 +63,7 @@
             KeyEntry(int ref, int key, int bits, int mask, int cmd, QString txt);
             ~KeyEntry();
             bool matches(int key, int bits, int mask);
+            bool metaspecified(void);
             QString text();
             int ref;
          private:
--- keytrans.cpp.orig	Mon Jul  1 15:52:43 2002
+++ keytrans.cpp	Mon Jul  1 16:06:23 2002
@@ -50,6 +50,11 @@
   return _key == key && (bits & m) == (_bits & m);
 }
 
+bool KeyTrans::KeyEntry::metaspecified(void)
+{
+  return (mask & BITS_Alt) && (bits & BITS_Alt);
+}
+
 QString KeyTrans::KeyEntry::text()
 {
   return txt;
@@ -109,7 +114,8 @@
   return (KeyEntry*)NULL;
 }
 
-bool KeyTrans::findEntry(int key, int bits, int* cmd, const char** txt, int* len)
+bool KeyTrans::findEntry(int key, int bits, int* cmd, const char** txt, int* len,
+		bool* metaspecified)
 {
   if (!m_fileRead) readConfig();
   for (QPtrListIterator<KeyEntry> it(tableX); it.current(); ++it)
@@ -118,6 +124,7 @@
       *cmd = it.current()->cmd;
       *txt = it.current()->txt.ascii();
       *len = it.current()->txt.length();
+      *metaspecified = it.current()->metaspecified();
       return true;
     }
   return false;
--- TEmuVt102.cpp.orig	Mon Jul  1 15:49:25 2002
+++ TEmuVt102.cpp	Mon Jul  1 16:06:29 2002
@@ -843,13 +843,14 @@
   int cmd = CMD_none; 
   const char* txt; 
   int len;
+  bool metaspecified;
   if (keytrans->findEntry(ev->key(), encodeMode(MODE_NewLine  , BITS_NewLine   ) + // OLD,
                                      encodeMode(MODE_Ansi     , BITS_Ansi      ) + // OBSOLETE,
                                      encodeMode(MODE_AppCuKeys, BITS_AppCuKeys ) + // VT100 stuff
                                      encodeStat(ControlButton , BITS_Control   ) +
                                      encodeStat(ShiftButton   , BITS_Shift     ) +
                                      encodeStat(AltButton     , BITS_Alt       ),
-                          &cmd, &txt, &len ))
+                          &cmd, &txt, &len, &metaspecified ))
 //printf("cmd: %d, %s, %d\n",cmd,txt,len);
   switch(cmd) // ... and execute if found.
   {
@@ -889,7 +890,7 @@
     scr->setHistCursor(scr->getHistLines());
 
   if (cmd==CMD_send) {
-    if (ev->state() & AltButton) sendString("\033");
+    if ((ev->state() & AltButton) && !metaspecified ) sendString("\033");
     emit sndBlock(txt,len);
     return;
   }

================================================================================

NOTE ! I can't set up here a compilation environment for kde, so I
haven't tested this patch, and I don't even now if it compiles !

If you don't like this approach, I would be happy with a configuration
option like the one in xterm to change globally the behaviour of Meta.
Note that the best might be to have both.

> > Could you revert it ?
> 
> I could, but don't want to. :-)

I am sure we will find a solution that will please everybody.

By the way, could you cc me in your answers ? I am not subscribed to
konsole-devel...

Éric Brunet




More information about the konsole-devel mailing list