Package lyntin :: Package ui :: Module base :: Class BaseUI
[show private | hide private]
[frames | no frames]

Class BaseUI


Base ui class.

This is the Base UI class which defines the interface between the ui's and Lyntin.
Method Summary
  __init__(self)
If you have initializations to do, override this class, but call this function like this:
  flush(self)
Flushes output to the user.
(string, int) get_completion(self, text, position)
This method should be called when some hotkey (usually "Tab", but it is up to the UI module) is being pressed.
[(string, int)] get_completion_list(self, text, position)
Returns the completion list.
  handleinput(self, input)
Nicely handles enqueuing of input events.
  prompt(self)
Prints a prompt to the user.
  reset_completion(self)
Resets the completion in progress.
  runui(self)
The engine executes this expecting your mainloop to start and you to take control of the main thread of execution.
boolean showTextForSession(self, ses)
Returns whether or not we should show text for this session--it's a convenience method.
  shutdown(self, args)
Tells the user interface thread to shutdown.
boolean wantMainThread(self)
This should return 0 (if you don't want the main thread of execution for the ui) or a 1 (if you do want the main thread of execution for the ui).
  write(self, args)
Writes output to the user.

Method Details

__init__(self)
(Constructor)

If you have initializations to do, override this class, but call this function like this:
 BaseUI.__init__(self)
then go on to do the initializing you need to do.

flush(self)

Flushes output to the user. Currently we don't do any flushing and it shouldn't be needed. I'm not wholly sure why it's here.

get_completion(self, text='', position=None)

This method should be called when some hotkey (usually "Tab", but it is up to the UI module) is being pressed.
Parameters:
text - the text to be completed
           (type=string)
position - cursor position in the text
           (type=int)
Returns:
next possible completion pair (newtext, newposition)
           (type=(string, int))

get_completion_list(self, text='', position=None)

Returns the completion list. Rebuilds the list if it is empty.
Parameters:
text - the text to be completed
           (type=string)
position - cursor position in the text
           (type=int)
Returns:
all possible completion pairs list [(newtext, newposition)]
           (type=[(string, int)])

handleinput(self, input)

Nicely handles enqueuing of input events. Also deals with things like CR and LF. Call this method with input that's just been polled from the user.
Parameters:
input - the raw input from the user
           (type=string)

prompt(self)

Prints a prompt to the user. This is mostly for niceties so the user knows that Lyntin is awaiting input. It should just print a prompt. Prompts only get printed by the common session.

reset_completion(self)

Resets the completion in progress. The next call to "get_completion" will reinitialize the completion list.

runui(self)

The engine executes this expecting your mainloop to start and you to take control of the main thread of execution. Put whatever other initialization you need to do here and then go into your main loop.

showTextForSession(self, ses)

Returns whether or not we should show text for this session--it's a convenience method.

We return a 1 if the session is None, it doesn't have a _snoop attribute, it's the current session, or get_config("snoop", ses) == 1.
Parameters:
ses - the session we're looking at--if it's None we return a 1
           (type=Session)
Returns:
1 if we should show text, 0 if not
           (type=boolean)

shutdown(self, args)

Tells the user interface thread to shutdown. This is registered with the shutdown_hook. Implement this method if you have shutdown stuff to do.
Parameters:
args - it's an empty tuple--we ignore this
           (type=tuple of 0 length)

wantMainThread(self)

This should return 0 (if you don't want the main thread of execution for the ui) or a 1 (if you do want the main thread of execution for the ui). This defaults to 0.
Returns:
0 or 1
           (type=boolean)

write(self, args)

Writes output to the user. Output can come from the mud, Lyntin, or even user input being printed to the screen. If the message argument is a String object rather than a Message object, the ui should assume it's Lyntin output.

This method should be registered with the to_user_hook.
Parameters:
args - either a string or a Message instance--this is the thing to be outputted to the user
           (type=tuple holding either a string or a Message instance)

Generated by Epydoc 2.1 on Mon Aug 9 09:17:41 2004 http://epydoc.sf.net