]> git.lyx.org Git - lyx.git/blobdiff - src/lyxfunc.C
Dekels tabular/textinset patches
[lyx.git] / src / lyxfunc.C
index ac9c22fbb9a089ff491032ab3c7f5200675ac01e..c0af8bd4cf160d98b097295e4daa1054c8af63cc 100644 (file)
@@ -91,8 +91,8 @@ using std::pair;
 using std::endl;
 using std::find_if;
 
-extern void math_insert_symbol(string const &);
-extern bool math_insert_greek(char);
+extern void math_insert_symbol(BufferView *, string const &);
+extern bool math_insert_greek(BufferView *, char);
 extern BufferList bufferlist;
 extern LyXServer * lyxserver;
 extern int greek_kb_flag;
@@ -270,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;
@@ -606,7 +637,7 @@ string const LyXFunc::Dispatch(int ac,
                                   (result == UpdatableInset::DISPATCHED_NOUPDATE))
                                return string();
                        else {
-                               setMessage(N_("Text mode"));
+                               //setMessage(N_("Text mode"));
                                switch (action) {
                                case LFUN_UNKNOWN_ACTION:
                                case LFUN_BREAKPARAGRAPH:
@@ -986,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:
@@ -1437,7 +1468,15 @@ string const LyXFunc::Dispatch(int ac,
                    && tmptext->cursor.par()->GetInset(tmptext->cursor.pos())->Editable() == Inset::HIGHLY_EDITABLE){
                        Inset * tmpinset = tmptext->cursor.par()->GetInset(tmptext->cursor.pos());
                        setMessage(tmpinset->EditMessage());
-                       tmpinset->Edit(owner->view(), 0, 0, 0);
+                       int y = 0;
+                       if (is_rtl) {
+                               LyXFont font = 
+                                       tmptext->GetFont(owner->view()->buffer(),
+                                                        tmptext->cursor.par(),
+                                                        tmptext->cursor.pos());        
+                               y = tmpinset->descent(owner->view(),font);
+                       }
+                       tmpinset->Edit(owner->view(), 0, y, 0);
                        break;
                }
                if (!is_rtl)
@@ -1459,7 +1498,7 @@ string const LyXFunc::Dispatch(int ac,
                LyXCursor cur = txt->cursor;
                if (!is_rtl)
                        txt->CursorLeft(owner->view(), false);
-               if ((cur != txt->cursor) && // only if really moved!
+               if ((is_rtl || cur != txt->cursor) && // only if really moved!
                    txt->cursor.pos() < txt->cursor.par()->Last() &&
                    (txt->cursor.par()->GetChar(txt->cursor.pos()) ==
                     LyXParagraph::META_INSET) &&
@@ -1472,11 +1511,12 @@ string const LyXFunc::Dispatch(int ac,
                        LyXFont font = txt->GetFont(owner->view()->buffer(),
                                                    txt->cursor.par(),
                                                    txt->cursor.pos());
+                       int y = is_rtl ? 0 
+                               : tmpinset->descent(owner->view(),font);
                        tmpinset->Edit(owner->view(),
                                       tmpinset->x() +
                                       tmpinset->width(owner->view(),font),
-                                      tmpinset->descent(owner->view(),font),
-                                      0);
+                                      y, 0);
                        break;
                }
                if  (is_rtl)
@@ -1813,7 +1853,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();
@@ -1923,13 +1963,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 {
@@ -2230,9 +2274,9 @@ string const LyXFunc::Dispatch(int ac,
                        ::sscanf(argument.c_str(),"%d%d", &r, &c);
                InsetTabular * new_inset =
                        new InsetTabular(*owner->buffer(), r, c);
-               if (owner->view()->insertInset(new_inset))
-                       new_inset->Edit(owner->view(), 0, 0, 0);
-               else
+               bool rtl =
+                       owner->view()->getLyXText()->real_current_font.isRightToLeft();
+               if (!owner->view()->open_new_inset(new_inset, rtl))
                        delete new_inset;
        }
        break;
@@ -2386,10 +2430,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
@@ -2479,7 +2529,7 @@ string const LyXFunc::Dispatch(int ac,
               
        case LFUN_INSERT_MATH:
        {
-               math_insert_symbol(argument);
+               math_insert_symbol(owner->view(), argument);
        }
        break;
        
@@ -2910,10 +2960,19 @@ string const LyXFunc::Dispatch(int ac,
                        for (string::size_type i = 0;
                             i < argument.length(); ++i) {
                                if (greek_kb_flag) {
-                                       if (!math_insert_greek(argument[i]))
+                                       if (!math_insert_greek(owner->view(),
+                                                              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);