]> git.lyx.org Git - lyx.git/blobdiff - src/lyxlookup.C
NEW_INSETS changes, + some small things in insettabular.C
[lyx.git] / src / lyxlookup.C
index 94c877ad9a9bcc36fbdfe2d2b724b0a67d4ba3f3..2a9c0778a1933b8c3a4572e131c38ff24896422d 100644 (file)
@@ -1,12 +1,12 @@
 /* This file is part of
-* ======================================================
-* 
-*           LyX, The Document Processor
-*       
-*          Copyright (C) 1995 Matthias Ettrich 
-*           Copyright (C) 1995-1998 The LyX team.
-*
-*======================================================*/
+ * ====================================================== 
+ 
+ *           LyX, The Document Processor
+ *      
+ *           Copyright 1995 Matthias Ettrich 
+ *           Copyright 1995-2000 The LyX team.
+ *
+ * ====================================================== */
 
 #include <config.h>
 
 #ifdef HAVE_LOCALE_H
 #include <locale.h>
 #endif
+#include <clocale>
 
-#include "error.h"
+#include "debug.h"
+#include "lyxrc.h"
+
+using std::endl;
 
 static XIM xim;
 static XIC xic;
-XComposeStatus compose_status={0,0};
+XComposeStatus compose_status= {0, 0};
 
 // This is called after the main LyX window has been created
-void InitLyXLookup(Display* display, Window window) 
+void InitLyXLookup(Display * display, Window window) 
 {
        xic = 0;
-
+       
        // This part could be done before opening display
-       setlocale(LC_CTYPE,"");
+       setlocale(LC_CTYPE, "");
                if (!XSupportsLocale()) {
-               lyxerr.debug("InitLyXLookup: X does not support this locale.");
+               lyxerr[Debug::KEY]
+                       << "InitLyXLookup: X does not support this locale."
+                       << endl;
                return;
        } 
        if (!XSetLocaleModifiers("")) {
-               lyxerr.debug("InitLyXLookup: Could not set modifiers "
-                            "for this locale.");
+               lyxerr[Debug::KEY] << "InitLyXLookup: Could not set modifiers "
+                       "for this locale." << endl;
                return;
        }
-
+       
        // This part will have to be done for each frame
        xim = XOpenIM (display, 0, 0, 0);
        if (xim) {
-               xic = XCreateIC (xim,  
-                           XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
-                           XNClientWindow, window,
-                           XNFocusWindow, window, 
-                           0);
+               xic = XCreateIC(xim, XNInputStyle,
+                               XIMPreeditNothing | XIMStatusNothing,
+                               XNClientWindow, window,
+                               XNFocusWindow, window, 
+                               0);
                
                if (!xic) {
-                       lyxerr.debug("InitLyXLookup: could not create "
-                                    "an input context");
+                       lyxerr[Debug::KEY] << "InitLyXLookup: could not create "
+                               "an input context" << endl;
                        XCloseIM (xim);
                        xim = 0;
                } 
        }
        else 
-               lyxerr.debug("InitLyXLookup: could not open "
-                            "an input method.");
-
+               lyxerr[Debug::KEY] << "InitLyXLookup: could not open "
+                       "an input method." << endl;
 }
 
 
 static
-bool isDeadEvent(XEvent *event,
-                 char *buffer_return, int bytes_buffer,
-                 KeySym *keysym_return)
+bool isDeadEvent(XEvent * event,
+                 char * buffer_return, int bytes_buffer,
+                 KeySym * keysym_return)
 {
        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;
+       }
 }
 
 
 // This is called instead of XLookupString()
-int LyXLookupString(XEvent *event,    
-                   char *buffer_return, int bytes_buffer,
-                   KeySym *keysym_return) 
+int LyXLookupString(XEvent * event,    
+                   char * buffer_return, int bytes_buffer,
+                   KeySym * keysym_return) 
 {
        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)) {
-                       //lyxerr.print("XFilterEvent");
+                       //lyxerr <<"XFilterEvent");
                        *keysym_return = NoSymbol;
                         return 0;
                }
                if (event->type != KeyPress)
-                       lyxerr.print("LyXLookupString: wrong event type" 
-                                     +string(event->type));
-               Status status_return;
+                       lyxerr << "LyXLookupString: wrong event type" 
+                              <<  event->type << endl;
+               Status status_return = 0;
                
                result =  XmbLookupString(xic, &event->xkey, buffer_return,
                                       bytes_buffer, keysym_return,
                                       &status_return);
                switch(status_return) {
                case XLookupBoth:
-                       //lyxerr.print("XLookupBoth");
+                       //lyxerr <<"XLookupBoth");
                        break;
                case XLookupChars:
-                       //lyxerr.print("XLookupChars");
+                       //lyxerr <<"XLookupChars");
                        *keysym_return = NoSymbol;
                        break;
                case XLookupKeySym:
-                       //lyxerr.print("XLookupKeySym");
+                       //lyxerr <<"XLookupKeySym");
                        result = 0;
                        break;
                default:
-                       //lyxerr.print("default");
+                       //lyxerr <<"default");
                        *keysym_return = NoSymbol;
                        result = 0;
                        break;
@@ -189,8 +202,10 @@ int LyXLookupString(XEvent *event,
 void CloseLyXLookup() 
 {
        if (xic) {
-               lyxerr.debug("CloseLyXLookup: destroying input context");
+               lyxerr[Debug::KEY] << "CloseLyXLookup: destroying input context"
+                              << endl;
                XDestroyIC(xic);
+               xic = 0;
                XCloseIM(xim);
        }
 }
@@ -201,19 +216,19 @@ void CloseLyXLookup()
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
 
-XComposeStatus compose_status={0,0};
+XComposeStatus compose_status= {0, 0};
 
 // This is called after the main LyX window has been created
-void InitLyXLookup(Display, Window ) 
+void InitLyXLookup(Display *, Window ) 
 {
        //Nothing to do.
 }
 
 // This is called instead of XLookupString(). I this particular case,
 // this *is* XLookupString...
-int LyXLookupString(XEvent *event,    
-                   char *buffer_return, int bytes_buffer,
-                   KeySym *keysym_return) 
+int LyXLookupString(XEvent * event,    
+                   char * buffer_return, int bytes_buffer,
+                   KeySym * keysym_return) 
 {
        return XLookupString(&event->xkey, buffer_return,
                                  bytes_buffer, keysym_return,
@@ -226,5 +241,4 @@ void CloseLyXLookup()
        // Nothing to do
 }
 
-
 #endif // HAVE_XOPENIM