]> git.lyx.org Git - lyx.git/blobdiff - src/lyxfunc.C
and back to cvs
[lyx.git] / src / lyxfunc.C
index 242c756850c9da2d917b4c53fa1b3c6b23d19fcf..5b586452845476712ad7476cab6efebe959347aa 100644 (file)
@@ -156,11 +156,12 @@ int LyXFunc::processKeySym(KeySym keysym, unsigned int state)
        
        if (lyxerr.debugging(Debug::KEY)) {
                char * tmp = XKeysymToString(keysym);
-               string stm = (tmp ? tmp : "");
+               string const stm = (tmp ? tmp : "");
                lyxerr << "KeySym is "
                       << stm
                       << "["
-                      << keysym << "]"
+                      << keysym << "] State is ["
+                      << state << "]"
                       << endl;
        }
        // Do nothing if we have nothing (JMarc)
@@ -204,17 +205,25 @@ int LyXFunc::processKeySym(KeySym keysym, unsigned int state)
        int action = cancel_meta_seq.addkey(keysym, state
                                            &(ShiftMask|ControlMask
                                              |Mod1Mask)); 
-
+       if (lyxerr.debugging(Debug::KEY)) {
+               lyxerr << "action first set to [" << action << "]" << endl;
+       }
+       
        // When not cancel or meta-fake, do the normal lookup. 
        // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
        // Mostly, meta_fake_bit = 0. RVDK_PATCH_5.
        if ((action != LFUN_CANCEL) && (action != LFUN_META_FAKE)) {
-
+               if (lyxerr.debugging(Debug::KEY)) {
+                       lyxerr << "meta_fake_bit is [" << meta_fake_bit << "]" << endl;
+               }
                // remove Caps Lock and Mod2 as a modifiers
                action = keyseq.addkey(keysym,
                                       (state | meta_fake_bit)
                                       &(ShiftMask|ControlMask
-                                        |Mod1Mask));      
+                                        |Mod1Mask));
+               if (lyxerr.debugging(Debug::KEY)) {
+                       lyxerr << "action now set to [" << action << "]" << endl;
+               }
        }
        // Dont remove this unless you know what you are doing.
        meta_fake_bit = 0;
@@ -249,7 +258,7 @@ int LyXFunc::processKeySym(KeySym keysym, unsigned int state)
                        return 0;
                }
        
-               char isochar = keyseq.getiso();
+               char const isochar = keyseq.getiso();
                if (!(state & ControlMask) &&
                    !(state & Mod1Mask) &&
                    (isochar && keysym < 0xF000)) {
@@ -261,7 +270,38 @@ int LyXFunc::processKeySym(KeySym keysym, unsigned int state)
                        // so we`ll skip the dispatch.
                        return 0;
                }
+       } else if (action == LFUN_SELFINSERT) {
+               // We must set the argument to the char looked up by
+               // XKeysymToString
+               XKeyEvent xke;
+               xke.type = KeyPress;
+               xke.serial = 0;
+               xke.send_event = False;
+               xke.display = fl_get_display();
+               xke.window = 0;
+               xke.root = 0;
+               xke.subwindow = 0;
+               xke.time = 0;
+               xke.x = 0;
+               xke.y = 0;
+               xke.x_root = 0;
+               xke.y_root = 0;
+               xke.state = state;
+               xke.keycode = XKeysymToKeycode(fl_get_display(), keysym);
+               xke.same_screen = True;
+               char ret[10];
+               KeySym tmpkeysym;
+               int res = XLookupString(&xke, ret, 10, &tmpkeysym, 0);
+               //Assert(keysym == tmpkeysym);
+               lyxerr[Debug::KEY] << "TmpKeysym ["
+                                  << tmpkeysym << "]" << endl;
+               
+               if (res > 0)
+                       argument = string(ret, res);
+               lyxerr[Debug::KEY] << "SelfInsert arg["
+                                  << argument << "]" << endl;
        }
+       
 
         bool tmp_sc = show_sc;
        show_sc = false;
@@ -418,13 +458,8 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
 
        if (buf) {
                func_status box = LyXFunc::ToggleOff;
-               LyXFont font;
-               if (owner->view()->theLockingInset() &&
-                   owner->view()->theLockingInset()->getLyXText(owner->view()))
-                   font = owner->view()->theLockingInset()->
-                       getLyXText(owner->view())->real_current_font;
-               else
-                   font = owner->view()->text->real_current_font;
+               LyXFont const & font =
+                       owner->view()->getLyXText()->real_current_font;
                switch (action) {
                case LFUN_EMPH:
                        if (font.emph() == LyXFont::ON)
@@ -472,7 +507,6 @@ string const LyXFunc::Dispatch(int ac,
        
        string argument;
        kb_action action;
-       LyXText * text = 0;
         
         // we have not done anything wrong yet.
         errorstat = false;
@@ -496,6 +530,9 @@ string const LyXFunc::Dispatch(int ac,
        if (owner->view()->available())
                owner->view()->hideCursor();
 
+       // We have to do this heare because of te goto below. (Lgb)
+       LyXText * text = owner->view()->getLyXText();
+
        // We cannot use this function here
        if (getStatus(ac) & Disabled)
                goto exit_with_message;
@@ -526,7 +563,8 @@ string const LyXFunc::Dispatch(int ac,
                                }
                        }
 
-                       string shortcuts = toplevel_keymap->findbinding(pseudoaction);
+                       string const shortcuts =
+                               toplevel_keymap->findbinding(pseudoaction);
 
                        if (!shortcuts.empty()) {
                                comname += ": " + shortcuts;
@@ -632,14 +670,8 @@ string const LyXFunc::Dispatch(int ac,
                                }
                        }
                }
-               if (owner->view()->theLockingInset())
-                       text = owner->view()->theLockingInset()->
-                               getLyXText(owner->view());
        }
 
-       if (!text)
-           text = owner->view()->text;
-
        switch (action) {
                // --- Misc -------------------------------------------
        case LFUN_WORDFINDFORWARD  : 
@@ -985,15 +1017,15 @@ string const LyXFunc::Dispatch(int ac,
                break;
                
        case LFUN_DEPTH:
-               changeDepth(owner->view(), 0);
+               changeDepth(owner->view(), text, 0);
                break;
                
        case LFUN_DEPTH_MIN:
-               changeDepth(owner->view(), -1);
+               changeDepth(owner->view(), text, -1);
                break;
                
        case LFUN_DEPTH_PLUS:
-               changeDepth(owner->view(), 1);
+               changeDepth(owner->view(), text, 1);
                break;
                
        case LFUN_FREE:
@@ -1812,7 +1844,7 @@ string const LyXFunc::Dispatch(int ac,
                                owner->view()->text->cursor;
                        owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
                        // It is possible to make it a lot faster still
-                       // just comment out the lone below...
+                       // just comment out the line below...
                        owner->view()->showCursor();
                } else {
                        owner->view()->cut();
@@ -1922,13 +1954,17 @@ string const LyXFunc::Dispatch(int ac,
        case LFUN_BACKSPACE:
        {
                if (!owner->view()->text->selection) {
+#if 0
                        if (owner->getIntl()->getTrans()->backspace()) {
+#else
+                       if (owner->getIntl()->getTrans().backspace()) {
+#endif
                                owner->view()->text->Backspace(owner->view());
                                owner->view()->text->sel_cursor = 
                                        owner->view()->text->cursor;
                                owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
                                // It is possible to make it a lot faster still
-                               // just comment out the lone below...
+                               // just comment out the line below...
                                owner->view()->showCursor();
                        }
                } else {
@@ -2385,10 +2421,16 @@ string const LyXFunc::Dispatch(int ac,
                
                if (keyseq.length == -1 && keyseq.getiso() != 0) 
                        c = keyseq.getiso();
-               
+
+#if 0
                owner->getIntl()->getTrans()->
                        deadkey(c, get_accent(action).accent, 
                                owner->view()->text);
+#else
+               owner->getIntl()->getTrans()
+                       .deadkey(c, get_accent(action).accent, 
+                               owner->view()->text);
+#endif
                
                // Need to reset, in case the minibuffer calls these
                // actions
@@ -2529,17 +2571,22 @@ string const LyXFunc::Dispatch(int ac,
        
        case LFUN_CITATION_CREATE:
        {
-               // Should do this "at source"
                InsetCommandParams p( "cite" );
                
-               if (contains(argument, "|")) {
-                       p.setContents( token(argument, '|', 0) );
-                       p.setOptions(  token(argument, '|', 1) );
-               } else {
-                       p.setContents( argument );
-               }
-
-               owner->getDialogs()->createCitation( p.getAsString() );
+               if (!argument.empty()) {
+                       // This should be set at source, ie when typing
+                       // "citation-insert foo" in the minibuffer.
+                       // Question: would pybibliographer also need to be
+                       // changed. Suspect so. Leave as-is therefore.
+                       if (contains(argument, "|")) {
+                               p.setContents( token(argument, '|', 0) );
+                               p.setOptions(  token(argument, '|', 1) );
+                       } else {
+                               p.setContents( argument );
+                       }
+                       Dispatch(LFUN_CITATION_INSERT, p.getAsString());
+               } else
+                       owner->getDialogs()->createCitation( p.getAsString() );
        }
        break;
                    
@@ -2905,9 +2952,17 @@ string const LyXFunc::Dispatch(int ac,
                             i < argument.length(); ++i) {
                                if (greek_kb_flag) {
                                        if (!math_insert_greek(argument[i]))
+#if 0
                                                owner->getIntl()->getTrans()->TranslateAndInsert(argument[i], owner->view()->text);
+#else
+                                               owner->getIntl()->getTrans().TranslateAndInsert(argument[i], owner->view()->text);
+#endif
                                } else
+#if 0
                                        owner->getIntl()->getTrans()->TranslateAndInsert(argument[i], owner->view()->text);
+#else
+                                       owner->getIntl()->getTrans().TranslateAndInsert(argument[i], owner->view()->text);
+#endif
                        }
 
                        owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);