New lyxrc command \override_x_deadkeys

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@729 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2000-05-10 11:50:11 +00:00
parent cee07433d6
commit 0ed7d49cb6
7 changed files with 154 additions and 109 deletions

View File

@ -1,3 +1,20 @@
2000-05-10 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* src/lyxlookup.C (isDeadEvent): use a switch statement instead of
a chain of "if". Return false when deadkeys are not handled.
* src/lyx_main.C (LyX): adapted the code for default bindings.
* src/kbmap.C (defaultKeyBindings): new method. Performs the default
bindings for basic functionality (except deadkeys).
(deadKeyBindings): new method. Performs the bindings of deadkeys.
* src/lyxrc.C (defaultKeyBindings): moved to lyx_main.C
several methods: handle override_x_deadkeys.
* src/lyxrc.h: remove the "bindings" map, which did not make much
sense anyway. New variable override_x_deadkeys, defaulting to "true".
2000-05-09 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* src/lyxfont.C (stateText): use a saner method to determine

View File

@ -51,6 +51,13 @@
# to this instead:
#\bind_file mine_is_best
# By default, LyX takes over the handling of the dead keys (or accent
# keys) that may be defined for your keyboard. While this allows you
# to enter characters that would not be normally available, some
# people dislike the different behaviour. You can use raw dead keys by
# just uncommenting the next line
#\override_x_deadkeys false
# Tip: Use "lyx -dbg 4" to survey how LyX interprets your keybindings.

View File

@ -69,13 +69,8 @@ LyX::LyX(int * argc, char * argv[])
// Global bindings (this must be done as early as possible.) (Lgb)
toplevel_keymap = new kb_keymap;
defaultKeyBindings(toplevel_keymap);
// Fill the toplevel_keymap with some defaults
for (LyXRC::Bindings::const_iterator cit = lyxrc.bindings.begin();
cit != lyxrc.bindings.end(); ++cit) {
toplevel_keymap->bind((*cit).first.c_str(), (*cit).second);
}
// Make the GUI object, and let it take care of the
// command line arguments that concerns it.
lyxerr[Debug::INIT] << "Initializing LyXGUI..." << endl;
@ -379,6 +374,12 @@ void LyX::init(int */*argc*/, char **argv, bool gui)
if (!lyxrc.hasBindFile)
lyxrc.ReadBindFile();
// Bind the X dead keys to the corresponding LyX functions if
// necessary.
if (lyxrc.override_x_deadkeys)
deadKeyBindings(toplevel_keymap);
if (lyxerr.debugging(Debug::LYXRC)) {
lyxrc.print();
}
@ -402,6 +403,81 @@ void LyX::init(int */*argc*/, char **argv, bool gui)
// lyxserver = new LyXServer;
}
// These are the default bindings known to LyX
void LyX::defaultKeyBindings(kb_keymap * kbmap)
{
kbmap->bind("Right", LFUN_RIGHT);
kbmap->bind("Left", LFUN_LEFT);
kbmap->bind("Up", LFUN_UP);
kbmap->bind("Down", LFUN_DOWN);
kbmap->bind("Tab", LFUN_TAB);
kbmap->bind("Home", LFUN_HOME);
kbmap->bind("End", LFUN_END);
kbmap->bind("Prior", LFUN_PRIOR);
kbmap->bind("Next", LFUN_NEXT);
kbmap->bind("Return", LFUN_BREAKPARAGRAPH);
kbmap->bind("~C-~S-~M-nobreakspace", LFUN_PROTECTEDSPACE);
kbmap->bind("Delete", LFUN_DELETE);
kbmap->bind("BackSpace", LFUN_BACKSPACE);
// kbmap->bindings to enable the use of the numeric keypad
// e.g. Num Lock set
kbmap->bind("KP_0", LFUN_SELFINSERT);
kbmap->bind("KP_Decimal", LFUN_SELFINSERT);
kbmap->bind("KP_Enter", LFUN_SELFINSERT);
kbmap->bind("KP_1", LFUN_SELFINSERT);
kbmap->bind("KP_2", LFUN_SELFINSERT);
kbmap->bind("KP_3", LFUN_SELFINSERT);
kbmap->bind("KP_4", LFUN_SELFINSERT);
kbmap->bind("KP_5", LFUN_SELFINSERT);
kbmap->bind("KP_6", LFUN_SELFINSERT);
kbmap->bind("KP_Add", LFUN_SELFINSERT);
kbmap->bind("KP_7", LFUN_SELFINSERT);
kbmap->bind("KP_8", LFUN_SELFINSERT);
kbmap->bind("KP_9", LFUN_SELFINSERT);
kbmap->bind("KP_Divide", LFUN_SELFINSERT);
kbmap->bind("KP_Multiply", LFUN_SELFINSERT);
kbmap->bind("KP_Subtract", LFUN_SELFINSERT);
/* Most self-insert keys are handled in the 'default:' section of
* WorkAreaKeyPress - so we don't have to define them all.
* However keys explicit decleared as self-insert are
* handled seperatly (LFUN_SELFINSERT.) Lgb. */
kbmap->bind("C-Tab", LFUN_TABINSERT); // ale970515
}
// LyX can optionally take over the handling of deadkeys
void LyX::deadKeyBindings(kb_keymap * kbmap)
{
// bindKeyings for transparent handling of deadkeys
// The keysyms are gotten from XFree86 X11R6
kbmap->bind("~C-~S-~M-dead_acute", LFUN_ACUTE);
kbmap->bind("~C-~S-~M-dead_breve", LFUN_BREVE);
kbmap->bind("~C-~S-~M-dead_caron", LFUN_CARON);
kbmap->bind("~C-~S-~M-dead_cedilla", LFUN_CEDILLA);
kbmap->bind("~C-~S-~M-dead_abovering", LFUN_CIRCLE);
kbmap->bind("~C-~S-~M-dead_circumflex", LFUN_CIRCUMFLEX);
kbmap->bind("~C-~S-~M-dead_abovedot", LFUN_DOT);
kbmap->bind("~C-~S-~M-dead_grave", LFUN_GRAVE);
kbmap->bind("~C-~S-~M-dead_doubleacute", LFUN_HUNG_UMLAUT);
kbmap->bind("~C-~S-~M-dead_macron", LFUN_MACRON);
// nothing with this name
// kbmap->bind("~C-~S-~M-dead_special_caron", LFUN_SPECIAL_CARON);
kbmap->bind("~C-~S-~M-dead_tilde", LFUN_TILDE);
kbmap->bind("~C-~S-~M-dead_diaeresis", LFUN_UMLAUT);
// nothing with this name either...
//kbmap->bind("~C-~S-~M-dead_underbar", LFUN_UNDERBAR);
kbmap->bind("~C-~S-~M-dead_belowdot", LFUN_UNDERDOT);
kbmap->bind("~C-~S-~M-dead_tie", LFUN_TIE);
kbmap->bind("~C-~S-~M-dead_ogonek", LFUN_OGONEK);
}
// This one is not allowed to use anything on the main form, since that
// one does not exist yet. (Asger)

View File

@ -23,7 +23,7 @@ class LyXGUI;
class LyXRC;
class LastFiles;
class Buffer;
class kb_keymap;
extern string system_lyxdir;
extern string user_lyxdir;
@ -76,6 +76,10 @@ private:
///
void init(int * argc, char * argv[], bool);
///
void defaultKeyBindings(kb_keymap * kbmap);
///
void deadKeyBindings(kb_keymap * kbmap);
///
void queryUserLyXDir();
///
void ReadRcFile(string const & name);

View File

@ -23,6 +23,7 @@
#include <clocale>
#include "debug.h"
#include "lyxrc.h"
using std::endl;
@ -79,63 +80,69 @@ bool isDeadEvent(XEvent * event,
XLookupString(&event->xkey, buffer_return,
bytes_buffer, keysym_return,
0);
// somehow it is necessary to do the lookup. Why? (JMarc)
if (!lyxrc.override_x_deadkeys)
return false;
// Can this be done safely in any other way?
// This is all the dead keys I know of in X11R6.1
if (false
switch (*keysym_return) {
#ifdef XK_dead_grave
|| *keysym_return == XK_dead_grave
case XK_dead_grave:
#endif
#ifdef XK_dead_acute
|| *keysym_return == XK_dead_acute
case XK_dead_acute:
#endif
#ifdef XK_dead_circumflex
|| *keysym_return == XK_dead_circumflex
case XK_dead_circumflex:
#endif
#ifdef XK_dead_tilde
|| *keysym_return == XK_dead_tilde
case XK_dead_tilde:
#endif
#ifdef XK_dead_macron
|| *keysym_return == XK_dead_macron
case XK_dead_macron:
#endif
#ifdef XK_dead_breve
|| *keysym_return == XK_dead_breve
case XK_dead_breve:
#endif
#ifdef XK_dead_abovedot
|| *keysym_return == XK_dead_abovedot
case XK_dead_abovedot:
#endif
#ifdef XK_dead_diaeresis
|| *keysym_return == XK_dead_diaeresis
case XK_dead_diaeresis:
#endif
#ifdef XK_dead_abovering
|| *keysym_return == XK_dead_abovering
case XK_dead_abovering:
#endif
#ifdef XK_dead_doubleacute
|| *keysym_return == XK_dead_doubleacute
case XK_dead_doubleacute:
#endif
#ifdef XK_dead_caron
|| *keysym_return == XK_dead_caron
case XK_dead_caron:
#endif
#ifdef XK_dead_cedilla
|| *keysym_return == XK_dead_cedilla
case XK_dead_cedilla:
#endif
#ifdef XK_dead_ogonek
|| *keysym_return == XK_dead_ogonek
case XK_dead_ogonek:
#endif
#ifdef XK_dead_iota
|| *keysym_return == XK_dead_iota
case XK_dead_iota:
#endif
#ifdef XK_dead_voiced_sound
|| *keysym_return == XK_dead_voiced_sound
case XK_dead_voiced_sound:
#endif
#ifdef XK_dead_semivoiced_sound
|| *keysym_return == XK_dead_semivoiced_sound
case XK_dead_semivoiced_sound:
#endif
#ifdef XK_dead_belowdot
|| *keysym_return == XK_dead_belowdot
case XK_dead_belowdot:
#endif
)
return true;
return false;
default:
return false;
}
}
@ -147,7 +154,9 @@ int LyXLookupString(XEvent * event,
int result = 0;
if (xic) {
if (isDeadEvent(event, buffer_return, bytes_buffer,
keysym_return)) {
keysym_return)) {
lyxerr[Debug::KEY]
<< "LyXLookupString: found DeadEvent" << endl;
return 0;
}
if (XFilterEvent (event, None)) {

View File

@ -95,6 +95,7 @@ enum LyXRCTags {
RC_LASTFILES,
RC_AUTOREGIONDELETE,
RC_BIND,
RC_OVERRIDE_X_DEADKEYS,
RC_SERVERPIPE,
RC_INPUT,
RC_BINDFILE,
@ -213,6 +214,7 @@ keyword_item lyxrcTags[] = {
{ "\\literate_extension", RC_LITERATE_EXTENSION },
{ "\\make_backup", RC_MAKE_BACKUP },
{ "\\num_lastfiles", RC_NUMLASTFILES },
{ "\\override_x_deadkeys", RC_OVERRIDE_X_DEADKEYS },
{ "\\pdf_mode", RC_PDF_MODE },
{ "\\pdf_to_ps_command", RC_PDF_TO_PS_COMMAND },
{ "\\pdflatex_command", RC_PDFLATEX_COMMAND },
@ -344,6 +346,7 @@ void LyXRC::setDefaults() {
popup_font_name = "-*-helvetica-medium-r";
font_norm = "iso8859-1";
font_norm_menu = "";
override_x_deadkeys = true;
autosave = 300;
auto_region_delete = true;
ascii_linelen = 75;
@ -383,9 +386,6 @@ void LyXRC::setDefaults() {
docbook_to_dvi_command="none";
docbook_to_html_command="none";
docbook_to_pdf_command="none";
//
defaultKeyBindings();
}
@ -885,6 +885,11 @@ int LyXRC::read(string const & filename)
}
break;
}
case RC_OVERRIDE_X_DEADKEYS:
if (lexrc.next())
override_x_deadkeys = lexrc.GetBool();
break;
case RC_SERVERPIPE:
if (lexrc.next())
lyxpipes = ExpandPath(lexrc.GetString());
@ -1194,6 +1199,9 @@ void LyXRC::output(ostream & os) const
os << " " << font_sizes[LyXFont::SIZE_HUGE];
os << " " << font_sizes[LyXFont::SIZE_HUGER];
os << "\n";
case RC_OVERRIDE_X_DEADKEYS:
os << "\\override_x_deadkeys "
<< override_x_deadkeys << "\n";
case RC_AUTOREGIONDELETE:
os << "\\auto_region_delete " << tostr(auto_region_delete)
<< "\n";
@ -1377,74 +1385,5 @@ void LyXRC::output(ostream & os) const
}
/// define the default key bindings for LyX.
void LyXRC::defaultKeyBindings()
{
bindings["Right"] = LFUN_RIGHT;
bindings["Left"] = LFUN_LEFT;
bindings["Up"] = LFUN_UP;
bindings["Down"] = LFUN_DOWN;
bindings["Tab"] = LFUN_TAB;
bindings["Home"] = LFUN_HOME;
bindings["End"] = LFUN_END;
bindings["Prior"] = LFUN_PRIOR;
bindings["Next"] = LFUN_NEXT;
bindings["Return"] = LFUN_BREAKPARAGRAPH;
bindings["~C-~S-~M-nobreakspace"] = LFUN_PROTECTEDSPACE;
bindings["Delete"] = LFUN_DELETE;
bindings["BackSpace"] = LFUN_BACKSPACE;
// bindKeyings for transparent handling of deadkeys
// The keysyms are gotten from XFree86 X11R6
bindings["~C-~S-~M-dead_acute"] = LFUN_ACUTE;
bindings["~C-~S-~M-dead_breve"] = LFUN_BREVE;
bindings["~C-~S-~M-dead_caron"] = LFUN_CARON;
bindings["~C-~S-~M-dead_cedilla"] = LFUN_CEDILLA;
bindings["~C-~S-~M-dead_abovering"] = LFUN_CIRCLE;
bindings["~C-~S-~M-dead_circumflex"] = LFUN_CIRCUMFLEX;
bindings["~C-~S-~M-dead_abovedot"] = LFUN_DOT;
bindings["~C-~S-~M-dead_grave"] = LFUN_GRAVE;
bindings["~C-~S-~M-dead_doubleacute"] = LFUN_HUNG_UMLAUT;
bindings["~C-~S-~M-dead_macron"] = LFUN_MACRON;
// nothing with this name
// bindings["~C-~S-~M-dead_special_caron"] = LFUN_SPECIAL_CARON;
bindings["~C-~S-~M-dead_tilde"] = LFUN_TILDE;
bindings["~C-~S-~M-dead_diaeresis"] = LFUN_UMLAUT;
// nothing with this name either...
//bindings["~C-~S-~M-dead_underbar"] = LFUN_UNDERBAR;
bindings["~C-~S-~M-dead_belowdot"] = LFUN_UNDERDOT;
bindings["~C-~S-~M-dead_tie"] = LFUN_TIE;
bindings["~C-~S-~M-dead_ogonek"] = LFUN_OGONEK;
// bindings to utilize the use of the numeric keypad
// e.g. Num Lock set
bindings["KP_0"] = LFUN_SELFINSERT;
bindings["KP_Decimal"] = LFUN_SELFINSERT;
bindings["KP_Enter"] = LFUN_SELFINSERT;
bindings["KP_1"] = LFUN_SELFINSERT;
bindings["KP_2"] = LFUN_SELFINSERT;
bindings["KP_3"] = LFUN_SELFINSERT;
bindings["KP_4"] = LFUN_SELFINSERT;
bindings["KP_5"] = LFUN_SELFINSERT;
bindings["KP_6"] = LFUN_SELFINSERT;
bindings["KP_Add"] = LFUN_SELFINSERT;
bindings["KP_7"] = LFUN_SELFINSERT;
bindings["KP_8"] = LFUN_SELFINSERT;
bindings["KP_9"] = LFUN_SELFINSERT;
bindings["KP_Divide"] = LFUN_SELFINSERT;
bindings["KP_Multiply"] = LFUN_SELFINSERT;
bindings["KP_Subtract"] = LFUN_SELFINSERT;
/* Most self-insert keys are handled in the 'default:' section of
* WorkAreaKeyPress - so we don't have to define them all.
* However keys explicit decleared as self-insert are
* handled seperatly (LFUN_SELFINSERT.) Lgb. */
bindings["C-Tab"] = LFUN_TABINSERT; // ale970515
}
// The global instance
LyXRC lyxrc;

View File

@ -16,8 +16,6 @@
#pragma interface
#endif
#include <map>
#include "ToolbarDefaults.h"
#include "bufferparams.h"
@ -146,6 +144,8 @@ public:
bool use_scalable_fonts;
/// DPI of monitor
float dpi;
/// Whether lyx should handle deadkeys by itself
bool override_x_deadkeys;
///
string fontenc;
///
@ -236,13 +236,6 @@ public:
string docbook_to_html_command;
///
string docbook_to_pdf_command;
///
typedef std::map<string, int> Bindings;
///
Bindings bindings;
private:
///
void defaultKeyBindings();
};
extern LyXRC lyxrc;