continuing keytrans changes

svn path=/trunk/kdebase/konsole/; revision=39721
wilder-portage
Lars Doelle 26 years ago
parent 3fb1836e07
commit 4d0e08bead
  1. 6
      include/MakeDefaults
  2. 15
      include/default.keytab.h
  3. 13
      include/keytrans.h
  4. 2
      include/main.h
  5. 7
      other/Makefile.am
  6. 15
      other/default.Keytab
  7. 151
      other/linux.keytab
  8. 151
      other/nobshack.keytab
  9. 4
      src/TEmuVt102.C
  10. 55
      src/keytrans.C
  11. 20
      src/main.C
  12. 3
      src/schema.C

@ -0,0 +1,6 @@
# [MakeDefaults] Quote default configuration files
# TODO. We should convert both schema and sessions
# to the method demonstrated for keytrans.
../tests/quote ../other/default.Keytab > default.keytab.h

@ -4,7 +4,7 @@
"#\n"
"# --------------------------------------------------------------\n"
"\n"
"hdr \"xterm keys\"\n"
"hdr \"xterm\"\n"
"\n"
"# --------------------------------------------------------------\n"
"#\n"
@ -65,15 +65,20 @@
"key Return+Alt-NewLine : \"\\E\\r\" \n"
"key Return+Alt+NewLine : \"\\E\\r\\n\"\n"
"\n"
"# NOTE: we remove exactly stuff like this.\n"
"# by means of this file\n"
"#\n"
"# Some desperately try to save the ^H.\n"
"# The BsHack mode is set by regular\n"
"# configurations means for convenience.\n"
"\n"
"key Backspace-BsHack : \"\\x08\"\n"
"key Delete -BsHack : \"\\x7f\"\n"
"# key Backspace-BsHack : \"\\x08\"\n"
"# key Delete -BsHack : \"\\x7f\"\n"
"# key Backspace+BsHack : \"\\x7f\"\n"
"# key Delete +BsHack : \"\\E[3~\"\n"
"\n"
"key Backspace+BsHack : \"\\x7f\"\n"
"key Delete +BsHack : \"\\E[3~\"\n"
"key Backspace : \"\\x7f\"\n"
"key Delete : \"\\E[3~\"\n"
"\n"
"# These codes are for the VT52 mode of VT100\n"
"# The Ansi mode (i.e. VT100 mode) is set by\n"

@ -43,10 +43,16 @@ public:
~KeyTrans();
static KeyTrans* defaultKeyTrans();
static KeyTrans* fromFile(const char* path);
static KeyTrans* find(int numb);
static KeyTrans* find(const char* path);
public:
static int count();
static void loadAll();
public:
bool findEntry(int key, int bits, int* cmd, const char** txt, int* len);
private:
static KeyTrans* fromDevice(QIODevice &buf);
void addKeyTrans();
static KeyTrans* fromDevice(QString path, QIODevice &buf);
void addEntry(int key, int bits, int mask, int cmd, QString txt);
private:
class KeyEntry
@ -66,8 +72,11 @@ private:
QString txt;
};
private:
QString hdr;
QList<KeyEntry> table;
public: //FIXME: we'd do better
QString hdr;
int numb;
QString path;
};
#endif

@ -113,6 +113,8 @@ private:
QPopupMenu* m_scrollbar;
QPopupMenu* m_font;
QPopupMenu* m_schema;
QPopupMenu* m_keytab;
QPopupMenu* m_codec;
QPopupMenu* m_size;
QPopupMenu* m_drop;
//

@ -2,10 +2,11 @@
datadir = $(kde_datadir)/konsole
data_DATA = BlackOnLightYellow.schema BlackOnWhite.schema \
Example.Schema GreenOnBlack.schema WhiteOnBlack.schema \
default.Schema linux.desktop mc.desktop shell.desktop \
syscolor.schema Linux.schema XTerm.schema vim.schema \
default.Schema syscolor.schema Linux.schema XTerm.schema vim.schema \
DarkPicture.schema LightPicture.schema Transparent.schema GreenTint.schema \
Transparent_MC.schema GreenTint_MC.schema su.desktop
Transparent_MC.schema GreenTint_MC.schema \
linux.desktop mc.desktop shell.desktop su.desktop \
linux.keytab nobshack.keytab
KDE_ICON = konsole

@ -2,7 +2,7 @@
#
# --------------------------------------------------------------
hdr "xterm keys"
hdr "xterm"
# --------------------------------------------------------------
#
@ -63,15 +63,20 @@ key Return-Alt+NewLine : "\r\n"
key Return+Alt-NewLine : "\E\r"
key Return+Alt+NewLine : "\E\r\n"
# NOTE: we remove exactly stuff like this.
# by means of this file
#
# Some desperately try to save the ^H.
# The BsHack mode is set by regular
# configurations means for convenience.
key Backspace-BsHack : "\x08"
key Delete -BsHack : "\x7f"
# key Backspace-BsHack : "\x08"
# key Delete -BsHack : "\x7f"
# key Backspace+BsHack : "\x7f"
# key Delete +BsHack : "\E[3~"
key Backspace+BsHack : "\x7f"
key Delete +BsHack : "\E[3~"
key Backspace : "\x7f"
key Delete : "\E[3~"
# These codes are for the VT52 mode of VT100
# The Ansi mode (i.e. VT100 mode) is set by

@ -0,0 +1,151 @@
# [KeyTab] Konsole Keyboard Table
#
# --------------------------------------------------------------
hdr "(NOT FUNCTIONAL, YET) Linux"
# --------------------------------------------------------------
#
# This configuration table allows to customize the
# meaning of the keys.
#
# The syntax is that each entry has the form :
#
# "key" Keyname { ("+"|"-") Modename } ":" (String|Operation)
#
# Keynames are those defined in <qnamespace.h> with the
# "Qt::Key_" removed. (We'd better insert the list here)
#
# Mode names are :
#
# - Shift
# - Alt
# - Control
#
# The VT100 emulation has two modes that can affect the
# sequences emitted by certain keys. These modes are
# under control of the client program.
#
# - Newline : effects Return and Enter key.
# - Application : effects Up and Down key.
# - Ansi : effects Up and Down key.
#
# konsole provides another mode that allows to configure
# the keyboard to do a backspace related trick. This mode
# can be changed by konsole's configuration menu.
#
# - BsHack : effects Backspace and Delete key.
#
# Operations are
#
# - scrollUpLine
# - scrollUpPage
# - scrollDownLine
# - scrollDownPage
#
# - emitSelection
#
# If the key is not found here, the text of the
# key event as provided by QT is emitted, possibly
# preceeded by ESC if the Alt key is pressed.
#
# --------------------------------------------------------------
key Escape : "\E"
key Tab : "\t"
# VT100 can add an extra \n after return.
# The NewLine mode is set by an escape sequence.
key Return-Alt-NewLine : "\r"
key Return-Alt+NewLine : "\r\n"
key Return+Alt-NewLine : "\E\r"
key Return+Alt+NewLine : "\E\r\n"
# Some desperately try to save the ^H.
# The BsHack mode is set by regular
# configurations means for convenience.
key Backspace-BsHack : "\x08"
key Delete -BsHack : "\x7f"
key Backspace+BsHack : "\x7f"
key Delete +BsHack : "\E[3~"
# These codes are for the VT52 mode of VT100
# The Ansi mode (i.e. VT100 mode) is set by
# an escape sequence
key Up -Shift-Ansi : "\EA"
key Down -Shift-Ansi : "\EB"
key Right-Ansi : "\EC"
key Left -Ansi : "\ED"
# VT100 emits a mode bit together
# with the arrow keys.The AppCuKeys
# mode is set by an escape sequence.
key Up -Shift+Ansi+AppCuKeys : "\EOA"
key Down -Shift+Ansi+AppCuKeys : "\EOB"
key Right+Ansi+AppCuKeys : "\EOC"
key Left +Ansi+AppCuKeys : "\EOD"
key Up -Shift+Ansi-AppCuKeys : "\E[A"
key Down -Shift+Ansi-AppCuKeys : "\E[B"
key Right+Ansi-AppCuKeys : "\E[C"
key Left +Ansi-AppCuKeys : "\E[D"
# linux functions keys F1-F5 differ from xterm
#
# F1 : "\E[[A"
# F2 : "\E[[B"
# F3 : "\E[[C"
# F4 : "\E[[D"
# F5 : "\E[[E"
# function keys
key F1 : "\E[11~"
key F2 : "\E[12~"
key F3 : "\E[13~"
key F4 : "\E[14~"
key F5 : "\E[15~"
key F6 : "\E[17~"
key F7 : "\E[18~"
key F8 : "\E[19~"
key F9 : "\E[20~"
key F10 : "\E[21~"
key F11 : "\E[23~"
key F12 : "\E[24~"
key Home : "\E[H"
key End : "\E[F"
key Prior -Shift : "\E[5~"
key Next -Shift : "\E[6~"
key Insert-Shift : "\E[2~"
# Keypad-Enter. See comment on Return above.
key Enter+NewLine : "\r\n"
key Enter-NewLine : "\r"
key Space +Control : "\x00"
# some of keys are used by konsole.
key Up +Shift : scrollLineUp
key Prior +Shift : scrollPageUp
key Down +Shift : scrollLineDown
key Next +Shift : scrollPageDown
key Insert+Shift : emitSelection
#----------------------------------------------------------
# keypad characters as offered by Qt
# cannot be recognized as such.
#----------------------------------------------------------
# Following other strings as emitted by konsole.

@ -0,0 +1,151 @@
# [KeyTab] Konsole Keyboard Table
#
# --------------------------------------------------------------
hdr "(NOT FUNCTIONAL, YET) BS sends BS"
# --------------------------------------------------------------
#
# This configuration table allows to customize the
# meaning of the keys.
#
# The syntax is that each entry has the form :
#
# "key" Keyname { ("+"|"-") Modename } ":" (String|Operation)
#
# Keynames are those defined in <qnamespace.h> with the
# "Qt::Key_" removed. (We'd better insert the list here)
#
# Mode names are :
#
# - Shift
# - Alt
# - Control
#
# The VT100 emulation has two modes that can affect the
# sequences emitted by certain keys. These modes are
# under control of the client program.
#
# - Newline : effects Return and Enter key.
# - Application : effects Up and Down key.
# - Ansi : effects Up and Down key.
#
# konsole provides another mode that allows to configure
# the keyboard to do a backspace related trick. This mode
# can be changed by konsole's configuration menu.
#
# - BsHack : effects Backspace and Delete key.
#
# Operations are
#
# - scrollUpLine
# - scrollUpPage
# - scrollDownLine
# - scrollDownPage
#
# - emitSelection
#
# If the key is not found here, the text of the
# key event as provided by QT is emitted, possibly
# preceeded by ESC if the Alt key is pressed.
#
# --------------------------------------------------------------
key Escape : "\E"
key Tab : "\t"
# VT100 can add an extra \n after return.
# The NewLine mode is set by an escape sequence.
key Return-Alt-NewLine : "\r"
key Return-Alt+NewLine : "\r\n"
key Return+Alt-NewLine : "\E\r"
key Return+Alt+NewLine : "\E\r\n"
# Some desperately try to save the ^H.
# The BsHack mode is set by regular
# configurations means for convenience.
key Backspace-BsHack : "\x08"
key Delete -BsHack : "\x7f"
key Backspace+BsHack : "\x7f"
key Delete +BsHack : "\E[3~"
# These codes are for the VT52 mode of VT100
# The Ansi mode (i.e. VT100 mode) is set by
# an escape sequence
key Up -Shift-Ansi : "\EA"
key Down -Shift-Ansi : "\EB"
key Right-Ansi : "\EC"
key Left -Ansi : "\ED"
# VT100 emits a mode bit together
# with the arrow keys.The AppCuKeys
# mode is set by an escape sequence.
key Up -Shift+Ansi+AppCuKeys : "\EOA"
key Down -Shift+Ansi+AppCuKeys : "\EOB"
key Right+Ansi+AppCuKeys : "\EOC"
key Left +Ansi+AppCuKeys : "\EOD"
key Up -Shift+Ansi-AppCuKeys : "\E[A"
key Down -Shift+Ansi-AppCuKeys : "\E[B"
key Right+Ansi-AppCuKeys : "\E[C"
key Left +Ansi-AppCuKeys : "\E[D"
# linux functions keys F1-F5 differ from xterm
#
# F1 : "\E[[A"
# F2 : "\E[[B"
# F3 : "\E[[C"
# F4 : "\E[[D"
# F5 : "\E[[E"
# function keys
key F1 : "\E[11~"
key F2 : "\E[12~"
key F3 : "\E[13~"
key F4 : "\E[14~"
key F5 : "\E[15~"
key F6 : "\E[17~"
key F7 : "\E[18~"
key F8 : "\E[19~"
key F9 : "\E[20~"
key F10 : "\E[21~"
key F11 : "\E[23~"
key F12 : "\E[24~"
key Home : "\E[H"
key End : "\E[F"
key Prior -Shift : "\E[5~"
key Next -Shift : "\E[6~"
key Insert-Shift : "\E[2~"
# Keypad-Enter. See comment on Return above.
key Enter+NewLine : "\r\n"
key Enter-NewLine : "\r"
key Space +Control : "\x00"
# some of keys are used by konsole.
key Up +Shift : scrollLineUp
key Prior +Shift : scrollPageUp
key Down +Shift : scrollLineDown
key Next +Shift : scrollPageDown
key Insert+Shift : emitSelection
#----------------------------------------------------------
# keypad characters as offered by Qt
# cannot be recognized as such.
#----------------------------------------------------------
# Following other strings as emitted by konsole.

@ -68,9 +68,7 @@ TEmuVt102::TEmuVt102(TEWidget* gui)
{
QObject::connect(gui,SIGNAL(mouseSignal(int,int,int)),
this,SLOT(onMouse(int,int,int)));
keytrans = KeyTrans::defaultKeyTrans();
//FIXME: allow to set another keyboard translator
//keytrans = KeyTrans::fromFile("../other/default.KeyMap");
keytrans = KeyTrans::find(0); //FIXME: go to proper config
initTokenizer();
reset();
}

@ -27,7 +27,10 @@
#include <qbuffer.h>
#include <qobject.h>
#include <qdict.h>
#include <qintdict.h>
#include <qfile.h>
#include <kglobal.h>
#include <kstddirs.h>
#include <stdio.h>
@ -58,6 +61,8 @@ QString KeyTrans::KeyEntry::text()
KeyTrans::KeyTrans()
{
path = "";
numb = 0;
}
KeyTrans::~KeyTrans()
@ -258,9 +263,10 @@ static KeyTransSymbols syms;
- Comment :: '#' (any but \n)*
*/
KeyTrans* KeyTrans::fromDevice(QIODevice &buf)
KeyTrans* KeyTrans::fromDevice(QString path, QIODevice &buf)
{
KeyTrans* kt = new KeyTrans;
kt->path = path;
// Opening sequence
@ -358,13 +364,13 @@ KeyTrans* KeyTrans::defaultKeyTrans()
#include "default.keytab.h"
;
QBuffer buf(txt);
return fromDevice(buf);
return fromDevice("[buildin]",buf);
}
KeyTrans* KeyTrans::fromFile(const char* path)
{
QFile file(path);
return fromDevice(file);
return fromDevice(path,file);
}
// local symbol tables ---------------------------------------------------------------------
@ -488,8 +494,49 @@ KeyTransSymbols::KeyTransSymbols()
defKeySyms();
}
// Debugging material -----------------------------------------------------------
// Global material -----------------------------------------------------------
static int keytab_serial = 0; //FIXME: remove,localize
static QIntDict<KeyTrans> numb2keymap;
static QDict<KeyTrans> path2keymap;
KeyTrans* KeyTrans::find(int numb)
{
KeyTrans* res = numb2keymap.find(numb);
return res ? res : numb2keymap.find(0);
}
KeyTrans* KeyTrans::find(const char* path)
{
KeyTrans* res = path2keymap.find(path);
return res ? res : numb2keymap.find(0);
}
int KeyTrans::count()
{
return numb2keymap.count();
}
void KeyTrans::addKeyTrans()
{
this->numb = keytab_serial ++;
numb2keymap.insert(numb,this);
path2keymap.insert(path.data(),this);
}
void KeyTrans::loadAll()
{
defaultKeyTrans()->addKeyTrans();
QStringList lst = KGlobal::dirs()->findAllResources("appdata", "*.keytab");
for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) {
KeyTrans* sc = KeyTrans::fromFile(*it);
if (sc) sc->addKeyTrans();
}
}
// Debugging material -----------------------------------------------------------
/*
void TestTokenizer(QBuffer &buf)
{

@ -183,7 +183,15 @@ Konsole::Konsole(const QString& name,
m_schema->insertItem(s->title.data(),s->numb);
}
//FIXME: we should build a complete session before running it.
// load schema /////////////////////////////////////////////////////////////
KeyTrans::loadAll();
//FIXME: sort
for (int i = 0; i < KeyTrans::count(); i++)
{ KeyTrans* s = KeyTrans::find(i);
assert( s );
m_keytab->insertItem(s->hdr.data(),s->numb);
}
// set global options ///////////////////////////////////////////////////////
@ -193,9 +201,8 @@ Konsole::Konsole(const QString& name,
: QFrame::NoFrame );
te->setScrollbarLocation(n_scroll);
//FIXME: call newSession here, somehow, instead the stuff below.
// construct initial session ///////////////////////////////////////////////
//FIXME: call newSession here, somehow, instead the stuff below.
TESession* initial = new TESession(this,te,pgm,args,"xterm");
@ -413,12 +420,11 @@ void Konsole::makeMenu()
m_schema->setCheckable(TRUE);
connect(m_schema, SIGNAL(activated(int)), SLOT(schema_menu_activated(int)));
QPopupMenu* m_keytab = new QPopupMenu;
m_keytab = new QPopupMenu;
m_keytab->setCheckable(TRUE);
m_keytab->insertItem( i18n("&xterm"), 1 );
m_keytab->setItemChecked(1,TRUE);
m_keytab->setItemChecked(0,TRUE);
QPopupMenu* m_codec = new QPopupMenu;
m_codec = new QPopupMenu;
m_codec->setCheckable(TRUE);
m_codec->insertItem( i18n("&locale"), 1 );
m_codec->setItemChecked(1,TRUE);

@ -20,9 +20,6 @@
static int schema_serial = 0; //FIXME: remove,localize
template class QIntDict<ColorSchema>;
template class QDict<ColorSchema>;
static QIntDict<ColorSchema> numb2schema;
static QDict<ColorSchema> path2schema;

Loading…
Cancel
Save