Laxkit  0.0.7.1
Public Member Functions | Public Attributes
Laxkit::ShortcutManager Class Reference
Inheritance diagram for Laxkit::ShortcutManager:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual int AddArea (const char *area, ShortcutDefs *cuts, WindowActions *actions)
virtual int AddArea (const char *area, ShortcutHandler *handler)
virtual int AreaParent (const char *area, const char *parent)
virtual ShortcutHandlerNewHandler (const char *area)
 Return a new ShortcutHandler object. The action and shortcut lists are refcounted, not duplicated.
virtual ShortcutHandlerFindHandler (const char *area)
 Return the installed handler for the given area.
virtual int Load (const char *file=NULL)
 Load from file if possible. If file==NULL, use setfile.
virtual int LoadKeysOnly (const char *file)
virtual int Save (const char *file=NULL, const char *header=NULL)
 Save to file, or to setfile if file==NULL.
virtual int SaveHTML (const char *file=NULL)
virtual void dump_out (FILE *f, int indent, int what, Laxkit::anObject *savecontext)
virtual void dump_in_atts (LaxFiles::Attribute *att, int flag, Laxkit::anObject *loadcontext)
virtual charShortcutString (ShortcutDef *def, char *buffer)
 Just call the other ShortcutString() with key and state.
virtual charShortcutString (unsigned int key, unsigned long state, char *buffer)
virtual int KeyAndState (const char *str, unsigned int *key, unsigned int *state)
virtual int ClearKeys ()
virtual int UpdateKey (const char *area, unsigned int key, unsigned int state, unsigned int mode, unsigned int newaction)
virtual int ReassignKey (const char *area, unsigned int newkey, unsigned int newstate, unsigned int oldkey, unsigned int oldstate, unsigned int mode, unsigned int action)
- Public Member Functions inherited from LaxFiles::DumpUtility
virtual Attributedump_out_atts (Attribute *att, int what, Laxkit::anObject *savecontext)
 Default is return NULL. what==0 means write out normal Attribute formatted things.
virtual void dump_in (FILE *f, int indent, int what, Laxkit::anObject *loadcontext, Attribute **att)
 Read in a file segment as an Attribute, and pass parsing duties to dump_in_atts.
virtual ~DumpUtility ()
 Empty virtual destructor.
- Public Member Functions inherited from Laxkit::anObject
 anObject ()
 Set object_id=getUniqueNumber().
virtual ~anObject ()
 Empty virtual destructor.
virtual const charwhattype ()
 Returns the type of anObject.
virtual anObjectduplicate (anObject *ref=NULL)
virtual int inc_count ()
 Increment the data's count by 1. Returns count.
virtual int dec_count ()
 Decrement the count of the data, deleting if count is less than or equal to 0.
virtual int the_count ()

Public Attributes

charsetname
charsetfile
LaxFiles::Attribute tree
RefPtrStack< ShortcutHandlershortcuts
- Public Attributes inherited from Laxkit::anObject
int suppress_debug
DeleteRefCountedFunc deleteMe
 Called when the count is decremented to 0.
unsigned long object_id
charobject_idstr

Additional Inherited Members

- Protected Attributes inherited from Laxkit::anObject
int _count
 The reference count of the object.

Detailed Description

Class to store collections of shortcuts and actions in a sort of input tree. This is basically a fancy stack of ShortcutHandler objects. Sometimes, there will be WindowAction things defined, but no bound shortcuts, or shortcuts that only are bound to numbers.


Member Function Documentation

int Laxkit::ShortcutManager::AddArea ( const char area,
ShortcutDefs cuts,
WindowActions actions 
)
virtual

Counts of cuts and actions incremented.

References Laxkit::anObject::dec_count(), and Laxkit::RefPtrStack< T >::push().

int Laxkit::ShortcutManager::ClearKeys ( )
virtual

Flush all key shortcuts, but keep all actions. This is used, for instance, with LoadKeysOnly(), which matches all keys to existing actions, but does not load actions. You would want to do this to ensure your application's current actions still exist after loading in a new key set.

References Laxkit::PtrStack< T >::e, Laxkit::PtrStack< T >::flush(), and Laxkit::PtrStack< T >::n.

void Laxkit::ShortcutManager::dump_in_atts ( LaxFiles::Attribute att,
int  flag,
Laxkit::anObject loadcontext 
)
virtual

If no handler is found for any particular area, then a new one is created.

If one IS found, then any old shortcut bindings are flushed in favor of the new ones. Care must be taken to ensure that there are WindowActions defined for the area BEFORE calling this! Otherwise, the non-number actions defined for the key will not map to anything meaningful.

Implements LaxFiles::DumpUtility.

References Laxkit::ShortcutHandler::AddShortcut(), Laxkit::anObject::dec_count(), Laxkit::PtrStack< T >::e, Laxkit::ShortcutHandler::FindActionNumber(), FindHandler(), isblank(), KeyAndState(), makestr(), Laxkit::PtrStack< T >::n, and Laxkit::RefPtrStack< T >::push().

void Laxkit::ShortcutManager::dump_out ( FILE *  f,
int  indent,
int  what,
Laxkit::anObject savecontext 
)
virtual
 * modifiers
 *    +^a,c,h,a,i,n   action 5               
 *    shift-alt-'c',h,a,i,n
 *    '+',''',','  someotheraction    # <-- a chain of '+' then apostrophe, then comma
 * 
Todo:
custom modifiers?

Implements LaxFiles::DumpUtility.

References LaxFiles::Attribute::dump_out(), Laxkit::PtrStack< T >::e, Laxkit::WindowActions::FindAction(), Laxkit::ShortcutDefs::FindShortcutFromAction(), isblank(), Laxkit::PtrStack< T >::n, and ShortcutString().

Referenced by Save().

ShortcutHandler * Laxkit::ShortcutManager::FindHandler ( const char area)
virtual

Return the installed handler for the given area.

If you are wanting to install a handler object in a window or interface, use NewHandler() instead, and that make a duplicate. The object returned here is merely for informational purposes.

References Laxkit::PtrStack< T >::e, and Laxkit::PtrStack< T >::n.

Referenced by dump_in_atts(), and UpdateKey().

int Laxkit::ShortcutManager::KeyAndState ( const char str,
unsigned int key,
unsigned int state 
)
virtual

Return 1 for success or 0 for fail. This is the reverse of ShortcutString().

Referenced by dump_in_atts().

int Laxkit::ShortcutManager::Load ( const char file = NULL)
virtual

Load from file if possible. If file==NULL, use setfile.

Set setfile to this file, if the load succeeds, else don't change setfile.

Return 0 for success, or nonzero for save fail.

References LaxFiles::DumpUtility::dump_in(), isblank(), lax_basename(), and makestr().

int Laxkit::ShortcutManager::LoadKeysOnly ( const char file)
virtual

If file==NULL, use setfile.

int Laxkit::ShortcutManager::Save ( const char file = NULL,
const char header = NULL 
)
virtual

Save to file, or to setfile if file==NULL.

Return 0 for success, or nonzero for save fail. If header is nonzero then first output that string, a newline, then dump_out().

References dump_out(), and makestr().

char * Laxkit::ShortcutManager::ShortcutString ( unsigned int  key,
unsigned long  state,
char buffer 
)
virtual

It would be good to have buffer at least 20 bytes long. buffer should be null terminated. The key string is strcat'd to it.

See KeyAndState() for the reverse of this.

References Laxkit::key_name_from_value().

int Laxkit::ShortcutManager::UpdateKey ( const char area,
unsigned int  key,
unsigned int  state,
unsigned int  mode,
unsigned int  newaction 
)
virtual

If replace!=0, then replace the action of the key and mode in area with the new action. Otherwise add it as an alternative. Return 0 for sucess, or nonzero for error, could not process.

References FindHandler(), and Laxkit::ShortcutHandler::UpdateKey().


The documentation for this class was generated from the following files:

Mon Feb 17 2014 11:53:00, Laxkit