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
|
|
|
|
|
2001-07-29 17:39:01 +00:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <sigc++/signal_system.h>
|
|
|
|
|
|
|
|
#include "commandtags.h" // for kb_action enum
|
2001-06-27 14:10:35 +00:00
|
|
|
#include "func_status.h"
|
2000-02-04 09:38:32 +00:00
|
|
|
#include "kbsequence.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "LString.h"
|
1999-11-22 16:19:48 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
class LyXView;
|
2001-07-29 17:39:01 +00:00
|
|
|
class LyXText;
|
2001-04-17 15:15:59 +00:00
|
|
|
|
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.
|
|
|
|
*/
|
2001-04-17 15:15:59 +00:00
|
|
|
class LyXFunc : public SigC::Object {
|
1999-09-27 18:44:28 +00:00
|
|
|
public:
|
|
|
|
///
|
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.
|
2001-07-16 15:42:57 +00:00
|
|
|
string const dispatch(int action, string const & arg = string());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// The same but uses the name of a lyx command.
|
2001-07-16 15:42:57 +00:00
|
|
|
string const dispatch(string const & cmd);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
///
|
|
|
|
void miniDispatch(string const & cmd);
|
2000-06-12 11:55:12 +00:00
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
///
|
|
|
|
void initMiniBuffer();
|
|
|
|
|
2000-08-14 15:31:16 +00:00
|
|
|
///
|
2001-05-17 01:23:29 +00:00
|
|
|
void processKeySym(KeySym k, unsigned int state);
|
2000-11-04 10:00:12 +00:00
|
|
|
|
2001-02-26 10:32:45 +00:00
|
|
|
/// we need one internall which is called from inside LyXAction and
|
|
|
|
/// can contain the string argument.
|
2001-06-27 14:10:35 +00:00
|
|
|
func_status::value_type getStatus(int ac) const;
|
2001-05-16 07:53:23 +00:00
|
|
|
///
|
2001-06-27 14:10:35 +00:00
|
|
|
func_status::value_type getStatus(int ac,
|
|
|
|
string const & not_to_use_arg) const;
|
1999-11-22 16:19:48 +00:00
|
|
|
|
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
|
2000-09-14 17:53:12 +00:00
|
|
|
string const 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
|
2000-09-14 17:53:12 +00:00
|
|
|
string const 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
|
2000-09-14 17:53:12 +00:00
|
|
|
string const getMessage() const { return dispatch_buffer; }
|
2001-02-23 16:10:03 +00:00
|
|
|
/// Handle a accented char keysequenze
|
|
|
|
void handleKeyFunc(kb_action action);
|
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;
|
|
|
|
///
|
2001-02-22 14:09:20 +00:00
|
|
|
void moveCursorUpdate(bool flag = true, bool selecting = false);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
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)
|
|
|
|
|
|
|
|
///
|
2001-07-16 15:42:57 +00:00
|
|
|
void menuNew(bool fromTemplate);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
///
|
2001-07-16 15:42:57 +00:00
|
|
|
void open(string const &);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
///
|
2000-04-28 11:18:04 +00:00
|
|
|
void doImport(string const &);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
///
|
2001-07-16 15:42:57 +00:00
|
|
|
void closeBuffer();
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
void reloadBuffer();
|
2001-02-22 14:09:20 +00:00
|
|
|
///
|
|
|
|
// This return or directly text (default) of getLyXText()
|
|
|
|
///
|
|
|
|
LyXText * TEXT(bool) const;
|
|
|
|
///
|
|
|
|
// This is the same for all lyxfunc objects
|
1999-09-27 18:44:28 +00:00
|
|
|
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
|
2000-09-14 17:53:12 +00:00
|
|
|
string const 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
|
2000-09-14 17:53:12 +00:00
|
|
|
string const 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|