/* This file is part of * ====================================================== * * LyX, The Document Processor * * Copyright (C) 1995 Matthias Ettrich * Copyright (C) 1995-1998 The LyX Team. *
*======================================================*/
if (tmp.empty()) { // get the arg from somewhere else, a popup, or ask for // it in the minibuffer.
}
lyxerr.debug("argAsString: <" + tmp + '>'); return tmp;
}
// I changed this func slightly. I commented out the ...FinishUndo(), // this means that all places that used to have a moveCursorUpdate, now // have a ...FinishUndo() as the preceeding statement. I have also added // a moveCursorUpdate to some of the functions that updated the cursor, but // that did not show its new position. inline void LyXFunc::moveCursorUpdate(bool selecting)
{ if (selecting || owner->currentBuffer()->text->mark_set) {
owner->currentBuffer()->text->SetSelection();
owner->currentView()->getScreen()->ToggleToggle();
owner->currentBuffer()->update(0);
} else {
owner->currentBuffer()->update(-2); // this IS necessary // (Matthias)
}
owner->currentView()->getScreen()->ShowCursor();
/* ---> Everytime the cursor is moved, show the current font state. */ // should this too me moved out of this func? //owner->getMiniBuffer()->Set(CurrentState());
}
int LyXFunc::processKeyEvent(XEvent *ev)
{ char s_r[10];
s_r[9] = '\0'; int num_bytes; int action; char *argument = 0;
XKeyEvent *keyevent = &ev->xkey;
KeySym keysym_return;
if (lyxerr.debugging(Error::KEY)) {
lyxerr.print(LString("KeySym is ")
+ XKeysymToString(keysym_return)
+ "["
+ int(keysym_return) + "]"
+ " and num_bytes is "
+ num_bytes
+ " the string returned is \""
+ LString(s_r) + '\"');
} // Do nothing if we have nothing (JMarc) if (num_bytes == 0 && keysym_return == NoSymbol) {
lyxerr.debug("Empty kbd action (probably composing)",
Error::KEY); return 0;
}
// this function should be used always [asierra060396] if (owner->currentView()->available() &&
owner->currentBuffer()->the_locking_inset &&
keysym_return == XK_Escape) {
UnlockInset(owner->currentBuffer()->the_locking_inset);
owner->currentBuffer()->text->CursorRight(); return 0;
}
// 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_return >= XK_Shift_L && keysym_return <= XK_Hyper_R)
|| keysym_return == XK_Mode_switch || keysym_return == 0x0) return 0;
// Do a one-deep top-level lookup for // cancel and meta-fake keys. RVDK_PATCH_5
cancel_meta_seq.reset();
// 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_return,
(keyevent->state | meta_fake_bit)
&(ShiftMask|ControlMask
|Mod1Mask));
} // Dont remove this unless you know what you are doing.
meta_fake_bit = 0;
if (action==-1) { if (keyseq.length<-1) { // unknown key sequence... char buf[100];
LyXBell();
keyseq.print(buf,100);
owner->getMiniBuffer()->Set(_("Unknown sequence:"),buf); return 0;
}
char isochar = keyseq.getiso(); if (!(keyevent->state&ControlMask) &&
!(keyevent->state&Mod1Mask) &&
(isochar && keysym_return < 0xF000)) {
argument = &s_r[0]; // shall this be here
argument[0] = isochar;
argument[1] = 0;
} if (!argument) {
lyxerr.debug("Empty argument!"); // This can`t possibly be of any use // so we`ll skip the dispatch. return 0;
}
} else if (action==LFUN_SELFINSERT) {
argument = &s_r[0];
argument[1] = 0;
}
// Need this for deadkeys (alkis) //keyseq.length=0; // ...but that breaks the minibuffer's display of "M-"... #ifdef WITH_WARNINGS #warning How does the deadkeys react to this? #endif return 0;
}
// we have not done anything wrong yet.
errorstat = false;
dispatch_buffer = LString();
// if action is a pseudo-action, we need the real action if (lyxaction.isPseudoAction(ac)) { charconst *tmparg = 0;
action = (kb_action)lyxaction.retrieveActionArg(ac, &tmparg); if (tmparg)
argument = tmparg;
} else {
action = (kb_action)ac;
argument = do_not_use_this_arg; // except here
}
selection_possible = false;
if (owner->currentView()->available()
&& owner->currentView()->getScreen())
owner->currentView()->getScreen()->HideCursor();
if(!owner->currentView()->available()) { // This lists the allowed funcs when we have no // buffer loaded switch(action){ case LFUN_MENU_OPEN_BY_NAME: case LFUN_PREFIX: case LFUN_MENUNEW: case LFUN_MENUNEWTMPLT: case LFUN_MENUOPEN: case LFUN_QUIT: case LFUN_PUSH_TOOLBAR: case LFUN_ADD_TO_TOOLBAR: case LFUN_EXEC_COMMAND: case LFUN_DROP_LAYOUTS_CHOICE: case LFUN_FILE_NEW: case LFUN_FILE_OPEN: case LFUN_IMPORT: case LFUN_RECONFIGURE: case LFUN_CANCEL: case LFUN_APROPOS: case LFUN_META_FAKE:
break; case LFUN_UNKNOWN_ACTION:
setErrorMessage(N_("Unknown action")); goto exit_with_message; default:
setErrorMessage(N_("Command not allowed with" "out any document open")); goto exit_with_message; // action not allowed
}
}
commandshortcut = LString();
if (lyxrc->display_shortcuts && show_sc) { if (action != LFUN_SELFINSERT) { // Put name of command and list of shortcuts // for it in minibuffer
LString comname = lyxaction.getActionName(action);
int pseudoaction = action; bool argsadded = false;
LString argu = argument; if (!argu.empty()) { // If we have the command with argument, // this is better
pseudoaction =
lyxaction.searchActionArg(action,
argument);
if (!comname.empty()) {
comname.strip();
commandshortcut = "(" + comname + ')';
owner->getMiniBuffer()->Set(commandshortcut); // Here we could even add a small pause, // to annoy the user and make him learn // the shortcuts. // No! That will just annoy, not teach // anything. The user will read the messages // if they are interested. (Asger)
}
}
}
// Now that we know which action, if the buffer is RO let's check // whether the action is legal. Alejandro 970603 if (owner->currentView()->available() &&
owner->currentBuffer()->isReadonly() &&
lyxaction.isFuncRO(action)) {
setErrorMessage(N_("Document is read-only"));
lyxerr.debug("Error: Document is read-only."); goto exit_with_message;
}
// If in math mode pass the control to // the math inset [asierra060396] if (owner->currentView()->available() &&
owner->currentBuffer()->the_locking_inset) { if (action>1 || (action==LFUN_UNKNOWN_ACTION && keyseq.length>=-1)) { char s[8]=""; if (action==LFUN_UNKNOWN_ACTION && !argument) {
sprintf(s, "%c", keyseq.getiso());
argument = &s[0];
} // Undo/Redo pre 0.13 is a bit tricky for insets. if (action==LFUN_UNDO) { int slx, sly;
UpdatableInset* inset =
owner->currentBuffer()->the_locking_inset;
inset->GetCursorPos(slx, sly);
UnlockInset(inset);
MenuUndo();
inset = (UpdatableInset*)owner->currentBuffer()->text->cursor.par->GetInset(owner->currentBuffer()->text->cursor.pos); if (inset)
inset->Edit(slx, sly); return LString();
} else if (action==LFUN_REDO) { int slx, sly;
UpdatableInset* inset = owner->currentBuffer()->the_locking_inset;
inset->GetCursorPos(slx, sly);
UnlockInset(inset);
MenuRedo();
inset = (UpdatableInset*)owner->currentBuffer()->text->cursor.par->GetInset(owner->currentBuffer()->text->cursor.pos); if (inset)
inset->Edit(slx, sly); return LString();
} else if (owner->currentBuffer()->the_locking_inset->LocalDispatch(action, argument)) return LString(); else {
setMessage(N_("Text mode")); if (action==LFUN_RIGHT || action==-1)
owner->currentBuffer()->text->CursorRight(); if (action==LFUN_LEFT || action==LFUN_RIGHT) return LString();
}
}
}
switch(action) { // --- Misc ------------------------------------------- case LFUN_WORDFINDFORWARD : case LFUN_WORDFINDBACKWARD : {
LyXText *ltCur; static LString last_search;
LString searched_string;
// ??? What is that ???
owner->currentView()->currentBuffer()->update(-2);
// ??? Needed ??? // clear the selection (if there is any)
owner->currentView()->getScreen()->ToggleSelection();
owner->currentView()->currentBuffer()->text->ClearSelection();
// Move cursor so that successive C-s 's will not stand in place. if( action == LFUN_WORDFINDFORWARD )
owner->currentBuffer()->text->CursorRightOneWord();
owner->currentBuffer()->text->FinishUndo();
moveCursorUpdate(false);
// ??? Needed ??? // set the new selection // SetSelectionOverLenChars(owner->currentView()->currentBuffer()->text, iLenSelected);
owner->currentView()->getScreen()->ToggleSelection(false);
} else
LyXBell();
// REMOVED : if (owner->currentView()->getWorkArea()->focus)
owner->currentView()->getScreen()->ShowCursor();
} break;
case LFUN_PREFIX:
{ if (owner->currentView()->available()
&& owner->currentView()->getScreen()) {
owner->currentBuffer()->update(-2);
} char buf[100];
keyseq.print(buf,100, true);
owner->getMiniBuffer()->Set(buf, LString(), LString(), 1);
} break;
// --- Misc ------------------------------------------- case LFUN_EXEC_COMMAND:
owner->getMiniBuffer()->ExecCommand(); break;
case LFUN_CANCEL: // RVDK_PATCH_5
keyseq.reset();
meta_fake_bit = 0; if(owner->currentView()->available()) // cancel any selection
Dispatch(int(LFUN_MARK_OFF), NULL);
setMessage(N_("Cancel")); break;
case LFUN_READ_ONLY_TOGGLE: if (owner->currentBuffer()->lyxvc.inUse()) {
owner->currentBuffer()->lyxvc.toggleReadOnly();
} else {
owner->currentBuffer()->setReadonly(
!owner->currentBuffer()->isReadonly());
} break;
case LFUN_CENTER: // this is center and redraw.
BeforeChange(); if (owner->currentBuffer()->text->cursor.y >
owner->currentView()->getWorkArea()->h / 2) {
owner->currentView()->getScreen()->
Draw(owner->currentBuffer()->text->cursor.y -
owner->currentView()->getWorkArea()->h/2);
} else { // <=
owner->currentView()->getScreen()->
Draw(0);
}
owner->currentBuffer()->update(0);
owner->currentView()->redraw(); break;
case LFUN_APPENDIX: if (owner->currentView()->available()) {
owner->currentBuffer()->text->toggleAppendix();
owner->currentBuffer()->update(1);
} break;
// --- Menus ----------------------------------------------- case LFUN_MENUNEW:
MenuNew(false); break;
case LFUN_MENUNEWTMPLT:
MenuNew(true); break;
case LFUN_MENUOPEN:
MenuOpen(); break;
case LFUN_CLOSEBUFFER:
CloseBuffer(); break;
case LFUN_MENUWRITE:
MenuWrite(owner->currentBuffer()); break;
case LFUN_MENUWRITEAS:
MenuWriteAs(owner->currentBuffer()); break;
case LFUN_MENURELOAD:
reloadBuffer(); break;
case LFUN_PREVIEW:
MenuPreview(owner->currentBuffer()); break;
case LFUN_PREVIEWPS:
MenuPreviewPS(owner->currentBuffer()); break;
case LFUN_RUNLATEX:
MenuRunLaTeX(owner->currentBuffer()); break;
case LFUN_RUNCHKTEX:
MenuRunChktex(owner->currentBuffer()); break;
case LFUN_RUNDVIPS:
MenuRunDvips(owner->currentBuffer(), false); break;
case LFUN_MENUPRINT:
MenuPrint(owner->currentBuffer()); break;
case LFUN_FAX:
MenuFax(owner->currentBuffer()); break;
case LFUN_EXPORT:
{ //needs argument as string
LString extyp=argAsString(argument);
// latex if (extyp == "latex") { // make sure that this buffer is not linuxdoc
MenuMakeLaTeX(owner->currentBuffer());
} // linuxdoc elseif (extyp == "linuxdoc") { // make sure that this buffer is not latex
MenuMakeLinuxDoc(owner->currentBuffer());
} // dvi elseif (extyp == "dvi") { // Run LaTeX as "Update dvi..." Bernhard. // We want the dvi in the current directory. This // is achieved by temporarily disabling use of // temp directory. As a side-effect, we get // *.log and *.aux files also. (Asger) bool flag = lyxrc->use_tempdir;
lyxrc->use_tempdir = false;
MenuRunLaTeX(owner->currentBuffer());
lyxrc->use_tempdir = flag;
} // postscript elseif (extyp == "postscript") { // Start Print-dialog. Not as good as dvi... Bernhard.
MenuPrint(owner->currentBuffer()); // Since the MenuPrint is a pop-up, we can't use // the same trick as above. (Asger) // MISSING: Move of ps-file :-(
} // ascii elseif (extyp == "ascii") {
MenuMakeAscii(owner->currentBuffer());
} elseif (extyp == "custom") {
MenuSendto(); break;
} else {
setErrorMessage(LString(N_("Unknown export type: "))
+ extyp);
}
} break;
case LFUN_IMPORT:
{ //needs argument as string
LString imtyp=argAsString(argument);
case LFUN_TOCVIEW:
TocUpdateCB(ob, 0); if (fd_form_toc->form_toc->visible) {
fl_raise_form(fd_form_toc->form_toc);
} else {
fl_show_form(fd_form_toc->form_toc,
FL_PLACE_MOUSE |
FL_FREE_SIZE, FL_FULLBORDER,
_("Table of Contents"));
} break;
case LFUN_TOC_INSERT:
{
Inset *new_inset = new InsetTOC(owner->currentBuffer());
owner->currentBuffer()->insertInset(new_inset, "Standard", true); break;
}
case LFUN_LOF_INSERT:
{
Inset *new_inset = new InsetLOF(owner->currentBuffer());
owner->currentBuffer()->insertInset(new_inset, "Standard", true); break;
}
case LFUN_LOA_INSERT:
{
Inset *new_inset = new InsetLOA(owner->currentBuffer());
owner->currentBuffer()->insertInset(new_inset, "Standard", true); break;
}
case LFUN_LOT_INSERT:
{
Inset *new_inset = new InsetLOT(owner->currentBuffer());
owner->currentBuffer()->insertInset(new_inset, "Standard", true); break;
}
case LFUN_TABLE:
TableCB(ob, 0); break;
case LFUN_FIGURE:
FigureCB(ob, 0); break;
case LFUN_AUTOSAVE:
AutoSave(); break;
case LFUN_UNDO:
MenuUndo(); break;
case LFUN_REDO:
MenuRedo(); break;
case LFUN_MENUSEARCH:
MenuSearch(); break;
case LFUN_PASTE:
PasteCB(); break;
case LFUN_PASTESELECTION:
{ bool asPara = false; if (LString(argument) == "paragraph") asPara = true;
MenuPasteSelection(asPara); break;
}
case LFUN_CUT:
CutCB(); break;
case LFUN_COPY:
CopyCB(); break;
case LFUN_LAYOUT_COPY:
CopyEnvironmentCB(); break;
case LFUN_LAYOUT_PASTE:
PasteEnvironmentCB(); break;
case LFUN_GOTOERROR:
owner->currentView()->gotoError(); break;
case LFUN_REMOVEERRORS: if (owner->currentBuffer()->removeAutoInsets()) {
owner->currentView()->redraw();
owner->currentView()->fitCursor();
owner->currentView()->updateScrollbar();
} break;
case LFUN_GOTONOTE:
GotoNote(); break;
case LFUN_OPENSTUFF:
OpenStuff(); break;
case LFUN_HYPHENATION:
HyphenationPoint(); break;
case LFUN_LDOTS:
Ldots(); break;
case LFUN_END_OF_SENTENCE:
EndOfSentenceDot(); break;
case LFUN_HFILL:
HFill(); break;
case LFUN_DEPTH:
DepthCB(ob, 0); break;
case LFUN_DEPTH_MIN:
DepthCB(ob, -1); break;
case LFUN_DEPTH_PLUS:
DepthCB(ob, 1); break;
case LFUN_FREE:
FreeCB(); break;
case LFUN_TEX:
TexCB(); break;
case LFUN_MELT:
MeltCB(ob, 0); break;
case LFUN_RECONFIGURE:
Reconfigure(); break;
case LFUN_FOOTMELT: if (owner->currentView()->available()
&& !owner->currentBuffer()->text->selection
&& owner->currentBuffer()->text->cursor.par->footnoteflag
!= LyXParagraph::NO_FOOTNOTE)
{ // only melt footnotes with FOOTMELT, not margins etc if(owner->currentBuffer()->text->cursor.par->footnotekind == LyXParagraph::FOOTNOTE)
MeltCB(ob,0);
} else
FootCB(ob, 0); break;
case LFUN_MARGINMELT: if (owner->currentView()->available()
&& !owner->currentBuffer()->text->selection
&& owner->currentBuffer()->text->cursor.par->footnoteflag
!= LyXParagraph::NO_FOOTNOTE)
{ // only melt margins if(owner->currentBuffer()->text->cursor.par->footnotekind == LyXParagraph::MARGIN)
MeltCB(ob,0);
} else
MarginCB(ob, 0); break;
// --- version control ------------------------------- case LFUN_VC_REGISTER:
{ if (!owner->currentBuffer()->lyxvc.inUse())
owner->currentBuffer()->lyxvc.registrer();
} break;
case LFUN_VC_CHECKIN:
{ if (owner->currentBuffer()->lyxvc.inUse()
&& !owner->currentBuffer()->isReadonly())
owner->currentBuffer()->lyxvc.checkIn();
} break;
case LFUN_VC_CHECKOUT:
{ if (owner->currentBuffer()->lyxvc.inUse()
&& owner->currentBuffer()->isReadonly())
owner->currentBuffer()->lyxvc.checkOut();
} break;
case LFUN_VC_REVERT:
{
owner->currentBuffer()->lyxvc.revert();
} break;
case LFUN_VC_UNDO:
{
owner->currentBuffer()->lyxvc.undoLast();
} break;
case LFUN_VC_HISTORY:
{
owner->currentBuffer()->lyxvc.showLog(); break;
}
// --- buffers ---------------------------------------- case LFUN_PREVBUFFER: #ifdef WITH_WARNINGS #warning fix this please #endif // it is the LyXView or the BufferView that should // remember the previous buffer, not bufferlist. // if (owner->currentView()->available()){ // BeforeChange(); // owner->currentBuffer()->update(-2); // } // owner->currentView()->setBuffer(bufferlist.prev());
case LFUN_FILE_NEW:
{ // servercmd: argument must be <file>:<template>
Buffer *tmpbuf = NewLyxFile(argument); if (tmpbuf)
owner->currentView()->setBuffer(tmpbuf);
} break;
case LFUN_FILE_OPEN:
owner->currentView()->setBuffer(
bufferlist.loadLyXFile(argument)); break;
case LFUN_LATEX_LOG:
ShowLatexLog(); break;
case LFUN_LAYOUTNO:
{
lyxerr.debug("LFUN_LAYOUTNO: (arg) " + LString(argument)); int sel = atoi(argument);
lyxerr.debug(LString("LFUN_LAYOUTNO: (sel) ") + int(sel));
// Should this give a setMessage instead? if (sel == 0) return LString(); // illegal argument
sel--; // sel 1..., but layout 0...
// Pretend we got the name instead.
Dispatch(int(LFUN_LAYOUT),
lyxstyle.NameOfLayout(owner->currentBuffer()->
text->parameters->
textclass,
sel).c_str()); return LString();
}
case LFUN_LAYOUT:
{
lyxerr.debug("LFUN_LAYOUT: (arg) "
+ LString(argument));
// Derive layout number from given argument (string) // and current buffer's textclass (number). */ int layoutno =
lyxstyle.NumberOfLayout(owner->
currentBuffer()->
text->parameters->
textclass,
argument);
// see if we found the layout number: if (layoutno == -1) {
setErrorMessage(LString(N_("Layout ")) + argument +
N_(" not known")); break;
}
case LFUN_DELETE:
FreeUpdateTimer(); if (!owner->currentBuffer()->text->selection) {
owner->currentBuffer()->text->Delete();
owner->currentBuffer()->text->sel_cursor =
owner->currentBuffer()->text->cursor;
SmallUpdate(1); // It is possible to make it a lot faster still // just comment out the lone below...
owner->currentView()->getScreen()->ShowCursor();
} else {
CutCB();
}
SetUpdateTimer(); break;
case LFUN_DELETE_SKIP:
{ // Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
/* -------> Delete word forward. */ case LFUN_DELETE_WORD_FORWARD:
owner->currentBuffer()->update(-2);
FreeUpdateTimer();
owner->currentBuffer()->text->DeleteWordForward();
owner->currentBuffer()->update( 1 );
SetUpdateTimer();
moveCursorUpdate(false); break;
/* -------> Delete word backward. */ case LFUN_DELETE_WORD_BACKWARD:
owner->currentBuffer()->update(-2);
FreeUpdateTimer();
owner->currentBuffer()->text->DeleteWordBackward();
owner->currentBuffer()->update( 1 );
SetUpdateTimer();
moveCursorUpdate(false); break;
/* -------> Kill to end of line. */ case LFUN_DELETE_LINE_FORWARD:
FreeUpdateTimer();
owner->currentBuffer()->update(-2);
owner->currentBuffer()->text->DeleteLineForward();
owner->currentBuffer()->update( 1 );
SetUpdateTimer();
moveCursorUpdate(false); break;
/* -------> Set mark off. */ case LFUN_MARK_OFF:
BeforeChange();
owner->currentBuffer()->update(0);
owner->currentBuffer()->text->sel_cursor =
owner->currentBuffer()->text->cursor;
setMessage(N_("Mark off")); break;
/* -------> Set mark on. */ case LFUN_MARK_ON:
BeforeChange();
owner->currentBuffer()->text->mark_set = 1;
owner->currentBuffer()->update( 0 );
owner->currentBuffer()->text->sel_cursor =
owner->currentBuffer()->text->cursor;
setMessage(N_("Mark on")); break;
case LFUN_BACKSPACE:
{
FreeUpdateTimer(); if (!owner->currentBuffer()->text->selection) { if (owner->getIntl()->getTrans()->backspace()) {
owner->currentBuffer()->text->Backspace();
owner->currentBuffer()->text->sel_cursor =
owner->currentBuffer()->text->cursor;
SmallUpdate(1); // It is possible to make it a lot faster still // just comment out the lone below...
owner->currentView()->getScreen()->ShowCursor();
}
} else {
CutCB();
}
SetUpdateTimer();
} break;
case LFUN_BACKSPACE_SKIP:
{ // Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
case LFUN_BREAKPARAGRAPH_SKIP:
{ // When at the beginning of a paragraph, remove // indentation and add a "defskip" at the top. // Otherwise, do the same as LFUN_BREAKPARAGRAPH.
case LFUN_QUOTE:
BeforeChange();
owner->currentBuffer()->text->InsertChar('\"'); // This " matches the single quote in the code
SmallUpdate(1);
SetUpdateTimer();
moveCursorUpdate(false); break;
case LFUN_HTMLURL: case LFUN_URL:
{
InsetCommand *new_inset; if (action == LFUN_HTMLURL)
new_inset = new InsetUrl("htmlurl", "", ""); else
new_inset = new InsetUrl("url", "", "");
owner->currentBuffer()->insertInset(new_inset);
new_inset->Edit(0, 0);
} break;
case LFUN_GOTOFILEROW:
{ char file_name[100]; int row;
sscanf(argument, " %s %d", file_name, &row);
// Must replace extension of the file to be .lyx and get full path
LString s = ChangeExtension(LString(file_name), ".lyx", false);
// Either change buffer or load the file if (bufferlist.exists(s))
owner->currentView()->setBuffer(bufferlist.getBuffer(s)); else
owner->currentView()->setBuffer(bufferlist.loadLyXFile(s));
// Set the cursor
owner->currentBuffer()->setCursorFromRow(row);
case LFUN_UMLAUT: case LFUN_CIRCUMFLEX: case LFUN_GRAVE: case LFUN_ACUTE: case LFUN_TILDE: case LFUN_CEDILLA: case LFUN_MACRON: case LFUN_DOT: case LFUN_UNDERDOT: case LFUN_UNDERBAR: case LFUN_CARON: case LFUN_SPECIAL_CARON: case LFUN_BREVE: case LFUN_TIE: case LFUN_HUNG_UMLAUT: case LFUN_CIRCLE: case LFUN_OGONEK:
{ char c;
if (keyseq.length==-1 && keyseq.getiso()!=0)
c=keyseq.getiso(); else
c=0;
case LFUN_MATH_DELIM: case LFUN_INSERT_MATRIX:
{ if (owner->currentView()->available()) {
owner->currentBuffer()->
open_new_inset(new InsetFormula(false));
owner->currentBuffer()->
the_locking_inset->LocalDispatch(action, argument);
}
} break;
case LFUN_INSERT_MATH:
{
math_insert_symbol(argument);
} break;
case LFUN_MATH_DISPLAY:
{ if (owner->currentView()->available())
owner->currentBuffer()->open_new_inset(new InsetFormula(true)); break;
}
case LFUN_MATH_MACRO:
{ if (owner->currentView()->available()) {
LString s(argument); if (s.empty())
setErrorMessage(N_("Missing argument")); else {
LString s1 = s.token(' ', 1); int na = s1.empty() ? 0: atoi(s1.c_str());
owner->currentBuffer()->
open_new_inset(new InsetFormulaMacro(s.token(' ', 0), na));
}
}
} break;
case LFUN_MATH_MODE: // Open or create a math inset
{
if (owner->currentView()->available())
owner->currentBuffer()->open_new_inset(new InsetFormula);
setMessage(N_("Math editor mode"));
} break;
case LFUN_MATH_NUMBER: case LFUN_MATH_LIMITS:
{
setErrorMessage(N_("This is only allowed in math mode!"));
} break;
case LFUN_INSERT_CITATION:
{
InsetCitation *new_inset = new InsetCitation(); // ale970405 // The note, if any, must be after the key, delimited // by a | so both key and remark can have spaces. if (argument) {
LString lsarg(argument); if (lsarg.contains("|")) {
new_inset->setContents(lsarg.token('|', 0));
new_inset->setOptions(lsarg.token('|', 1));
} else
new_inset->setContents(lsarg);
owner->currentBuffer()->insertInset(new_inset);
} else {
owner->currentBuffer()->insertInset(new_inset);
new_inset->Edit(0,0);
}
} break;
case LFUN_INSERT_BIBTEX:
{ // ale970405+lasgoutt970425 // The argument can be up to two tokens separated // by a space. The first one is the bibstyle.
LString lsarg(argument);
LString bibstyle = lsarg.token(' ', 1); if (bibstyle.empty())
bibstyle = "plain";
InsetBibtex *new_inset
= new InsetBibtex(lsarg.token(' ', 0),
bibstyle,
owner->currentBuffer());
owner->currentBuffer()->insertInset(new_inset); if (lsarg.empty()) {
new_inset->Edit(0,0);
}
} break;
// BibTeX data bases case LFUN_BIBDB_ADD:
{
InsetBibtex *inset =
(InsetBibtex*)getInsetByCode(Inset::BIBTEX_CODE); if (inset) {
inset->addDatabase(argument);
}
} break;
case LFUN_BIBDB_DEL:
{
InsetBibtex *inset =
(InsetBibtex*)getInsetByCode(Inset::BIBTEX_CODE); if (inset) {
inset->delDatabase(argument);
}
} break;
case LFUN_BIBTEX_STYLE:
{
InsetBibtex *inset =
(InsetBibtex*)getInsetByCode(Inset::BIBTEX_CODE); if (inset) {
inset->setOptions(argument);
}
} break;
case LFUN_INDEX_INSERT: case LFUN_INDEX_INSERT_LAST:
{
InsetIndex *new_inset = new InsetIndex(); if (argument) {
LString lsarg(argument);
new_inset->setContents(lsarg);
owner->currentBuffer()->insertInset(new_inset);
} else { //reh 98/09/21 //get the current word for an argument
// grab a word
int lastpos =owner->currentBuffer()->text->cursor.pos-1;
//this shouldn't happen, but let's be careful if (lastpos < 0) lastpos=0;
// get the current word // note that this must be done before // inserting the inset, or the inset will break // the word
LString curstring(owner->currentBuffer()->text->cursor.par->GetWord(lastpos));
//make the new inset and write the current word into it
InsetIndex *new_inset = new InsetIndex();
new_inset->setContents(curstring);
//don't edit it if the call was to INSERT_LAST if(action!=LFUN_INDEX_INSERT_LAST) {
new_inset->Edit(0,0);
} else { //it looks blank on the screen unless //we do something. put it here.
// move the cursor to the returned value of lastpos // but only for the auto-insert
owner->currentBuffer()->text->cursor.pos=lastpos;
}
//put the new inset into the buffer. // there should be some way of knowing the user //cancelled & avoiding this, but i don't know how
owner->currentBuffer()->insertInset(new_inset);
}
} break;
case LFUN_INDEX_PRINT:
{
Inset *new_inset = new InsetPrintIndex(owner->currentBuffer());
owner->currentBuffer()->insertInset(new_inset, "Standard", true);
} break;
case LFUN_PARENTINSERT:
{
lyxerr.print(LString("arg ") + argument);
Inset *new_inset = new InsetParent(argument, owner->currentBuffer());
owner->currentBuffer()->insertInset(new_inset, "Standard", true);
} break;
case LFUN_CHILDINSERT:
{
Inset *new_inset = new InsetInclude(argument,owner->currentBuffer());
owner->currentBuffer()->insertInset(new_inset, "Standard", true);
new_inset->Edit(0,0);
} break;
case LFUN_BUFFERBULLETSSELECT:
bulletForm(); break;
case LFUN_TOGGLECURSORFOLLOW:
cursor_follows_scrollbar = !cursor_follows_scrollbar; break;
case LFUN_KMAP_OFF: // keymap off
owner->getIntl()->KeyMapOn(false); break;
case LFUN_KMAP_PRIM: // primary keymap
owner->getIntl()->KeyMapPrim(); break;
case LFUN_KMAP_SEC: // secondary keymap
owner->getIntl()->KeyMapSec(); break;
case LFUN_KMAP_TOGGLE: // toggle keymap
owner->getIntl()->ToggleKeyMap(); break;
case LFUN_SELFINSERT:
{
LString const text = argument; for (int i=0; i<text.length(); i++) {
owner->currentBuffer()->text->InsertChar(text[i]); // This needs to be in the loop, or else we // won't break lines correctly. (Asger)
SmallUpdate(1);
}
SetUpdateTimer();
owner->currentBuffer()->text->sel_cursor =
owner->currentBuffer()->text->cursor;
moveCursorUpdate(false);
} break;
case LFUN_UNKNOWN_ACTION:
{ if (owner->currentBuffer()->isReadonly()) {
LyXBell();
setErrorMessage(N_("Document is read only")); break;
}
if (argument) {
/* Automatically delete the currently selected * text and replace it with what is being * typed in now. Depends on lyxrc settings * "auto_region_delete", which defaults to
* true (on). */
if ( lyxrc->auto_region_delete ) { if (owner->currentBuffer()->text->selection){
owner->currentBuffer()->text->CutSelection(false);
owner->currentBuffer()->update(-1);
}
}
BeforeChange(); for(charconst *p = argument; *p; p++) { if (greek_kb_flag) { if (!math_insert_greek(*p))
owner->getIntl()->getTrans()->TranslateAndInsert(*p, owner->currentBuffer()->text);
} else
owner->getIntl()->getTrans()->TranslateAndInsert(*p, owner->currentBuffer()->text);
}
SmallUpdate(1);
SetUpdateTimer();
owner->currentBuffer()->text->sel_cursor =
owner->currentBuffer()->text->cursor;
moveCursorUpdate(false); return LString();
} else { // why is an "Unknown action" with empty // argument even dispatched in the first // place? I`ll probably change that. (Lgb)
LyXBell();
setErrorMessage(N_("Unknown action"));
} break; default:
lyxerr.print("A truly unknown func!"); break;
}
} // end of switch
exit_with_message:
if (owner->currentView()->available()) {
LString trypath = owner->currentBuffer()->filepath; // If directory is writeable, use this as default. if (IsDirWriteable(trypath) == 1)
initpath = trypath;
}
ProhibitInput();
fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
fileDlg.SetButton(1, _("Templates"), lyxrc->template_path);
fname = fileDlg.Select(_("Enter Filename for new document"),
initpath, "*.lyx", _("newfile"));
AllowInput();
if (fname.empty()) {
owner->getMiniBuffer()->Set(_("Canceled."));
lyxerr.debug("New Document Cancelled."); return;
}
// get absolute path of file and make sure the filename ends // with .lyx
LString s = MakeAbsPath(fname); if (!IsLyXFilename(s))
s += ".lyx";
// Check if the document already is open if (bufferlist.exists(s)){ switch(AskConfirmation(_("Document is already open:"),
MakeDisplayPath(s,50),
_("Do you want to close that document now?\n" "('No' will just switch to the open version)")))
{ case 1: // Yes: close the document if (!bufferlist.close(bufferlist.getBuffer(s))) // If close is canceled, we cancel here too. return; break; case 2: // No: switch to the open document
owner->currentView()->setBuffer(bufferlist.getBuffer(s)); return; case 3: // Cancel: Do nothing
owner->getMiniBuffer()->Set(_("Canceled.")); return;
}
}
// Check whether the file already exists if (IsLyXFilename(s)) {
FilePtr myfile(s, FilePtr::read); if (myfile() &&
AskQuestion(_("File already exists:"),
MakeDisplayPath(s,50),
_("Do you want to open the document?"))) { // loads document
owner->getMiniBuffer()->Set(_("Opening document"),
MakeDisplayPath(s), "...");
XFlush(fl_display);
owner->currentView()->setBuffer(
bufferlist.loadLyXFile(s));
owner->getMiniBuffer()->Set(_("Document"),
MakeDisplayPath(s),
_("opened.")); return;
}
}
if (owner->currentView()->available()) {
LString trypath = owner->currentBuffer()->filepath; // If directory is writeable, use this as default. if (IsDirWriteable(trypath) == 1)
initpath = trypath;
}
// check selected filename if (filename.empty()) {
owner->getMiniBuffer()->Set(_("Canceled.")); return;
}
// get absolute path of file and make sure the filename ends // with .lyx
filename = MakeAbsPath(filename); if (!IsLyXFilename(filename))
filename += ".lyx";
// loads document
owner->getMiniBuffer()->Set(_("Opening document"),
MakeDisplayPath(filename), "...");
Buffer * openbuf = bufferlist.loadLyXFile(filename); if (openbuf) {
owner->currentView()->setBuffer(openbuf);
owner->getMiniBuffer()->Set(_("Document"),
MakeDisplayPath(filename),
_("opened."));
} else {
owner->getMiniBuffer()->Set(_("Could not open document"),
MakeDisplayPath(filename));
}
}
if (owner->currentView()->available()) {
LString trypath = owner->currentBuffer()->filepath; // If directory is writeable, use this as default. if (IsDirWriteable(trypath) == 1)
initpath = trypath;
}
// check selected filename if (filename.empty()) {
owner->getMiniBuffer()->Set(_("Canceled.")); return;
}
// get absolute path of file
filename = MakeAbsPath(filename);
LString s = ChangeExtension(filename, ".lyx", false);
// Check if the document already is open if (bufferlist.exists(s)){ switch(AskConfirmation(_("Document is already open:"),
MakeDisplayPath(s,50),
_("Do you want to close that document now?\n" "('No' will just switch to the open version)")))
{ case 1: // Yes: close the document if (!bufferlist.close(bufferlist.getBuffer(s))) // If close is canceled, we cancel here too. return; break; case 2: // No: switch to the open document
owner->currentView()->setBuffer(bufferlist.getBuffer(s)); return; case 3: // Cancel: Do nothing
owner->getMiniBuffer()->Set(_("Canceled.")); return;
}
}
// Check if a LyX document by the same root exists in filesystem
FileInfo f(s, true); if (f.exist() && !AskQuestion(_("A document by the name"),
MakeDisplayPath(s),
_("already exists. Overwrite?"))) {
owner->getMiniBuffer()->Set(_("Canceled.")); return;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.