1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
1999-10-07 18:44:17 +00:00
|
|
|
#ifndef LYXFUNC_H
|
|
|
|
#define LYXFUNC_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "commandtags.h"
|
2000-02-04 09:38:32 +00:00
|
|
|
#include "kbsequence.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "insets/lyxinset.h"
|
|
|
|
#include "LString.h"
|
1999-11-22 16:19:48 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
class LyXView;
|
2000-06-12 11:55:12 +00:00
|
|
|
class auto_mem_buffer;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/** This class encapsulates all the LyX command operations.
|
|
|
|
This is the class of the LyX's "high level event handler".
|
|
|
|
Every user command is processed here, either invocated from
|
|
|
|
keyboard or from the GUI. All GUI objects, including buttons and
|
|
|
|
menus should use this class and never call kernel functions directly.
|
|
|
|
*/
|
|
|
|
class LyXFunc {
|
|
|
|
public:
|
1999-11-22 16:19:48 +00:00
|
|
|
/// The status of a function.
|
|
|
|
enum func_status {
|
|
|
|
OK = 0, // No problem
|
|
|
|
Unknown = 1,
|
|
|
|
Disabled = 2, // Command cannot be executed
|
|
|
|
ToggleOn = 4,
|
|
|
|
ToggleOff = 8
|
|
|
|
};
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-04-08 17:02:02 +00:00
|
|
|
explicit
|
1999-11-22 16:19:48 +00:00
|
|
|
LyXFunc(LyXView *);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
/// LyX dispatcher, executes lyx actions.
|
1999-11-22 16:19:48 +00:00
|
|
|
string Dispatch(int action, char const * arg = 0);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// The same but uses the name of a lyx command.
|
1999-11-22 16:19:48 +00:00
|
|
|
string Dispatch(string const & cmd);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-06-12 11:55:12 +00:00
|
|
|
/// Same again but for xtl buffers. Still looking for better idea.
|
|
|
|
bool Dispatch(int action, auto_mem_buffer &);
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/// A keyboard event is processed to execute a lyx action.
|
1999-11-22 16:19:48 +00:00
|
|
|
int processKeyEvent(XEvent * ev);
|
|
|
|
|
|
|
|
///
|
|
|
|
func_status getStatus(int ac) const;
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/// The last key was meta
|
1999-11-22 16:19:48 +00:00
|
|
|
bool wasMetaKey() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-12-16 06:43:25 +00:00
|
|
|
// These can't be global because are part of the
|
|
|
|
// internal state (ale970227)
|
1999-09-27 18:44:28 +00:00
|
|
|
/// Get the current keyseq string
|
1999-12-16 06:43:25 +00:00
|
|
|
string keyseqStr() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// Is the key sequence uncomplete?
|
1999-11-22 16:19:48 +00:00
|
|
|
bool keyseqUncomplete() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// get options for the current keyseq
|
1999-12-16 06:43:25 +00:00
|
|
|
string keyseqOptions() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// True if lyxfunc reports an error
|
|
|
|
bool errorStat() const { return errorstat; }
|
|
|
|
/// Buffer to store result messages
|
1999-11-22 16:19:48 +00:00
|
|
|
void setMessage(string const & m);
|
1999-09-27 18:44:28 +00:00
|
|
|
/// Buffer to store result messages
|
1999-11-22 16:19:48 +00:00
|
|
|
void setErrorMessage(string const &) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
/// Buffer to store result messages
|
1999-10-02 16:21:10 +00:00
|
|
|
string getMessage() const { return dispatch_buffer; }
|
1999-09-27 18:44:28 +00:00
|
|
|
/// Get next inset of this class from current cursor position
|
1999-11-22 16:19:48 +00:00
|
|
|
Inset * getInsetByCode(Inset::Code);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// Should a hint message be displayed?
|
|
|
|
void setHintMessage(bool);
|
|
|
|
private:
|
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
LyXView * owner;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
static int psd_idx;
|
|
|
|
///
|
|
|
|
kb_sequence keyseq;
|
|
|
|
///
|
|
|
|
kb_sequence cancel_meta_seq;
|
|
|
|
///
|
|
|
|
unsigned meta_fake_bit;
|
|
|
|
///
|
|
|
|
void moveCursorUpdate(bool selecting = false);
|
|
|
|
///
|
|
|
|
void setupLocalKeymap();
|
|
|
|
///
|
|
|
|
kb_action lyx_dead_action;
|
|
|
|
///
|
|
|
|
kb_action lyx_calling_dead_action;
|
|
|
|
/// Error status, only Dispatch can change this flag
|
1999-11-22 16:19:48 +00:00
|
|
|
mutable bool errorstat;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/** Buffer to store messages and result data. Is there a
|
1999-12-16 06:43:25 +00:00
|
|
|
good reason to have this one as static in Dispatch? (Ale)
|
|
|
|
*/
|
1999-11-22 16:19:48 +00:00
|
|
|
mutable string dispatch_buffer;
|
1999-09-27 18:44:28 +00:00
|
|
|
/// Command name and shortcut information
|
1999-10-02 16:21:10 +00:00
|
|
|
string commandshortcut;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// I think the following should be moved to BufferView. (Asger)
|
|
|
|
|
|
|
|
///
|
|
|
|
void MenuNew(bool fromTemplate);
|
|
|
|
|
|
|
|
///
|
|
|
|
void MenuOpen();
|
|
|
|
|
|
|
|
///
|
2000-04-28 11:18:04 +00:00
|
|
|
void doImport(string const &);
|
|
|
|
void doImportHelper(string const &, string const &, string const &,
|
|
|
|
bool func(BufferView *, string const &) );
|
2000-03-20 18:55:57 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
void MenuInsertLyXFile(string const &);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
void CloseBuffer();
|
|
|
|
///
|
|
|
|
void reloadBuffer();
|
|
|
|
/// This is the same for all lyxfunc objects
|
|
|
|
static bool show_sc;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------- inlines --------------------------*/
|
|
|
|
|
|
|
|
inline
|
1999-11-22 16:19:48 +00:00
|
|
|
bool LyXFunc::wasMetaKey() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
return (meta_fake_bit != 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
1999-12-16 06:43:25 +00:00
|
|
|
string LyXFunc::keyseqStr() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-12-16 06:43:25 +00:00
|
|
|
// Why not just remove this function
|
|
|
|
string text;
|
|
|
|
keyseq.print(text, true);
|
|
|
|
return text;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
1999-12-16 06:43:25 +00:00
|
|
|
string LyXFunc::keyseqOptions() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-12-16 06:43:25 +00:00
|
|
|
// Why not just remove this function
|
|
|
|
string text;
|
|
|
|
keyseq.printOptions(text);
|
|
|
|
return text;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
1999-11-22 16:19:48 +00:00
|
|
|
bool LyXFunc::keyseqUncomplete() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
return (keyseq.length > 0);
|
|
|
|
}
|
|
|
|
|
1999-12-16 06:43:25 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
inline
|
|
|
|
void LyXFunc::setHintMessage(bool hm)
|
|
|
|
{
|
|
|
|
show_sc = hm;
|
|
|
|
}
|
|
|
|
|
1999-12-16 06:43:25 +00:00
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
inline
|
|
|
|
void operator|=(LyXFunc::func_status & fs, LyXFunc::func_status f)
|
|
|
|
{
|
|
|
|
fs = static_cast<LyXFunc::func_status>(fs | f);
|
|
|
|
}
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#endif
|