#include "menus.h"
#endif
#include "FloatList.h"
+#include "exporter.h"
+#include "FontLoader.h"
+#include "TextCache.h"
using std::pair;
using std::endl;
extern bool MenuWrite(Buffer *);
extern bool MenuWriteAs(Buffer *);
+#ifdef NEW_MENUBAR
extern int MenuRunLaTeX(Buffer *);
+#endif
extern int MenuBuildProg(Buffer *);
extern int MenuRunChktex(Buffer *);
+#ifndef NEW_EXPORT
extern bool CreatePostscript(Buffer *, bool);
+#endif
extern void MenuPrint(Buffer *);
extern void MenuSendto();
extern void QuitLyX();
extern void MenuFax(Buffer *);
+#ifndef NEW_EXPORT
extern void MenuExport(Buffer *, string const &);
+#endif
extern void show_symbols_form(LyXFunc *);
extern LyXAction lyxaction;
extern tex_accent_struct get_accent(kb_action action);
extern void AutoSave(BufferView *);
+#ifndef NEW_EXPORT
extern bool PreviewDVI(Buffer *);
extern bool PreviewPostscript(Buffer *);
+#endif
extern void MenuInsertLabel(char const *);
extern void MenuLayoutCharacter();
extern void MenuLayoutParagraph();
}
+int LyXFunc::processKeySym(KeySym keysym, unsigned int state)
+{
+ string argument;
+
+ if (lyxerr.debugging(Debug::KEY)) {
+ char * tmp = XKeysymToString(keysym);
+ string stm = (tmp ? tmp : "");
+ lyxerr << "KeySym is "
+ << stm
+ << "["
+ << keysym << "]"
+ << endl;
+ }
+ // Do nothing if we have nothing (JMarc)
+ if (keysym == NoSymbol) {
+ lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
+ << endl;
+ //return 0;
+ return FL_PREEMPT;
+ }
+
+ // this function should be used always [asierra060396]
+ UpdatableInset * tli = owner->view()->the_locking_inset;
+ if (owner->view()->available() && tli && (keysym == XK_Escape)) {
+ if (tli == tli->GetLockingInset()) {
+ owner->view()->unlockInset(tli);
+ owner->view()->text->CursorRight(owner->view());
+ moveCursorUpdate(false);
+ owner->showState();
+ } else {
+ tli->UnlockInsetInInset(owner->view(),
+ tli->GetLockingInset(),true);
+ }
+ //return 0;
+ return FL_PREEMPT;
+ }
+
+ // Can we be sure that this will work for all X-Windows
+ // implementations? (Lgb)
+ // This code snippet makes lyx ignore some keys. Perhaps
+ // all of them should be explictly mentioned?
+ if((keysym >= XK_Shift_L && keysym <= XK_Hyper_R)
+ || keysym == XK_Mode_switch || keysym == 0x0)
+ return 0;
+
+ // Do a one-deep top-level lookup for
+ // cancel and meta-fake keys. RVDK_PATCH_5
+ cancel_meta_seq.reset();
+
+ int action = cancel_meta_seq.addkey(keysym, state
+ &(ShiftMask|ControlMask
+ |Mod1Mask));
+
+ // 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) ) {
+
+ // remove Caps Lock and Mod2 as a modifiers
+ action = keyseq.addkey(keysym,
+ (state | meta_fake_bit)
+ &(ShiftMask|ControlMask
+ |Mod1Mask));
+ }
+ // Dont remove this unless you know what you are doing.
+ meta_fake_bit = 0;
+
+ if (action == 0) action = LFUN_PREFIX;
+
+ if (lyxerr.debugging(Debug::KEY)) {
+ string buf;
+ keyseq.print(buf);
+ lyxerr << "Key ["
+ << action << "]["
+ << buf << "]"
+ << endl;
+ }
+
+ // already here we know if it any point in going further
+ // why not return already here if action == -1 and
+ // num_bytes == 0? (Lgb)
+
+ if(keyseq.length > 1 || keyseq.length < -1) {
+ string buf;
+ keyseq.print(buf);
+ owner->getMiniBuffer()->Set(buf);
+ }
+
+ if (action == -1) {
+ if (keyseq.length < -1) { // unknown key sequence...
+ string buf;
+ LyXBell();
+ keyseq.print(buf);
+ owner->getMiniBuffer()->Set(_("Unknown sequence:"), buf);
+ return 0;
+ }
+
+ char isochar = keyseq.getiso();
+ if (!(state & ControlMask) &&
+ !(state & Mod1Mask) &&
+ (isochar && keysym < 0xF000)) {
+ argument += isochar;
+ }
+ if (argument.empty()) {
+ lyxerr.debug() << "Empty argument!" << endl;
+ // This can`t possibly be of any use
+ // so we`ll skip the dispatch.
+ return 0;
+ }
+ }
+
+ bool tmp_sc = show_sc;
+ show_sc = false;
+ Dispatch(action, argument.c_str());
+ show_sc = tmp_sc;
+
+ return 0;
+}
+
+
+#if 0
int LyXFunc::processKeyEvent(XEvent * ev)
{
char s_r[10];
+ KeySym keysym_return = 0;
string argument;
XKeyEvent * keyevent = &ev->xkey;
- KeySym keysym_return = 0;
-
int num_bytes = LyXLookupString(ev, s_r, 10, &keysym_return);
s_r[num_bytes] = '\0';
<< " and num_bytes is "
<< num_bytes
<< " the string returned is \""
- << s_r << '\"' << endl;
+ << s_r << '\"'
+ << endl;
}
// Do nothing if we have nothing (JMarc)
if (num_bytes == 0 && keysym_return == NoSymbol) {
keyseq.print(buf);
lyxerr << "Key ["
<< action << "]["
- << buf << "]["
- << num_bytes << "]" << endl;
+ << buf << "]"
+ << "["
+ << num_bytes << "]"
+ << endl;
}
// already here we know if it any point in going further
// so we`ll skip the dispatch.
return 0;
}
- } else
+ }
+ else
if (action == LFUN_SELFINSERT) {
argument = s_r[0];
}
-
+
bool tmp_sc = show_sc;
show_sc = false;
Dispatch(action, argument.c_str());
return 0;
}
+#endif
LyXFunc::func_status LyXFunc::getStatus(int ac) const
static bool noLaTeX = lyxrc.latex_command == "none";
bool disable = false;
switch (action) {
+#ifndef NEW_EXPORT
case LFUN_PREVIEW:
disable = noLaTeX || lyxrc.view_dvi_command == "none";
break;
case LFUN_RUNDVIPS:
disable = noLaTeX;
break;
+#endif
case LFUN_MENUPRINT:
disable = noLaTeX || lyxrc.print_command == "none";
break;
else if (argument == "linuxdoc")
disable = lyxrc.linuxdoc_to_lyx_command == "none";
break;
+#ifndef NEW_EXPORT
case LFUN_EXPORT:
if (argument == "latex")
disable = (! buf->isLatex() && ! buf->isLiterate()) ;
else if (argument == "custom")
disable = (! buf->isLatex() && ! buf->isLiterate());
break;
+#endif
case LFUN_UNDO:
disable = buf->undostack.empty();
break;
case LFUN_TABULAR_FEATURE:
disable = true;
if (owner->view()->the_locking_inset) {
- int ret = 0;
+ func_status ret = LyXFunc::Disabled;
if (owner->view()->the_locking_inset->LyxCode() == Inset::TABULAR_CODE) {
ret = static_cast<InsetTabular *>
(owner->view()->the_locking_inset)->
GetFirstLockingInsetOfType(Inset::TABULAR_CODE))->
getStatus(argument);
}
- switch(ret) {
- case 0:
- break;
- case 1:
- disable = false;
- break;
- case 2:
- disable = false;
- flag |= LyXFunc::ToggleOn;
- break;
- case 3:
- disable = false;
- flag |= LyXFunc::ToggleOff;
- break;
- }
+ flag |= ret;
+ disable = false;
+ } else {
+ static InsetTabular inset(owner->buffer(), 1, 1);
+ func_status ret;
+
+ disable = true;
+ ret = inset.getStatus(argument);
+ if ((ret & LyXFunc::ToggleOn) ||
+ (ret & LyXFunc::ToggleOff))
+ flag |= LyXFunc::ToggleOff;
}
break;
if (buf) {
func_status box = LyXFunc::ToggleOff;
- LyXFont font = owner->view()->text->real_current_font;
+ LyXFont font;
+ if (owner->view()->the_locking_inset &&
+ owner->view()->the_locking_inset->getLyXText(owner->view()))
+ font = owner->view()->the_locking_inset->
+ getLyXText(owner->view())->real_current_font;
+ else
+ font = owner->view()->text->real_current_font;
switch (action) {
case LFUN_EMPH:
if (font.emph() == LyXFont::ON)
reloadBuffer();
break;
+#ifdef NEW_EXPORT
+ case LFUN_UPDATE:
+ Exporter::Export(owner->buffer(), argument, true);
+ break;
+
+ case LFUN_PREVIEW:
+ Exporter::Preview(owner->buffer(), argument);
+ break;
+#else
case LFUN_PREVIEW:
PreviewDVI(owner->buffer());
break;
case LFUN_RUNLATEX:
MenuRunLaTeX(owner->buffer());
break;
+
+ case LFUN_RUNDVIPS:
+ CreatePostscript(owner->buffer(), false);
+ break;
+#endif
case LFUN_BUILDPROG:
MenuBuildProg(owner->buffer());
case LFUN_RUNCHKTEX:
MenuRunChktex(owner->buffer());
break;
-
- case LFUN_RUNDVIPS:
- CreatePostscript(owner->buffer(), false);
- break;
-
+
case LFUN_MENUPRINT:
owner->getDialogs()->showPrint();
break;
break;
case LFUN_EXPORT:
+#ifdef NEW_EXPORT
+ Exporter::Export(owner->buffer(), argument, false);
+#else
MenuExport(owner->buffer(), argument);
+#endif
break;
case LFUN_IMPORT:
break;
}
- case LFUN_TABLE:
+ case LFUN_DIALOG_TABULAR_INSERT:
#ifndef NEW_TABULAR
Table();
#else
break;
case LFUN_LAYOUT_DOCUMENT:
+#ifdef USE_OLD_DOCUMENT_LAYOUT
MenuLayoutDocument();
+#else
+ owner->getDialogs()->showLayoutDocument();
+#endif
break;
case LFUN_LAYOUT_PARAGRAPH:
break;
case LFUN_LAYOUT_PAPER:
+#ifdef USE_OLD_DOCUMENT_LAYOUT
MenuLayoutPaper();
+#endif
break;
case LFUN_LAYOUT_QUOTES:
+#ifdef USE_OLD_DOCUMENT_LAYOUT
MenuLayoutQuotes();
+#endif
break;
case LFUN_LAYOUT_PREAMBLE:
}
break;
+ case LFUN_SCREEN_FONT_UPDATE:
+ {
+ // handle the screen font changes.
+ //
+ lyxrc.set_font_norm_type();
+ fontloader.update();
+ // Of course we should only do the resize and the textcache.clear
+ // if values really changed...but not very important right now. (Lgb)
+ // All buffers will need resize
+ bufferlist.resize();
+ // We also need to empty the textcache so that
+ // the buffer will be formatted correctly after
+ // a zoom change.
+ textcache.clear();
+ }
+
case LFUN_SET_COLOR:
{
string lyx_name, x11_name;