Esempio n. 1
0
  def runtimer(self):
    """
    This timer thread sleeps for a second, then calls everything
    in the queue with the current tick.
    """
    from time import time
    
    self._current_tick = 0
    wakeup_time = current_time = time()

    import threading
    ev = threading.Event()
    exported.hook_register("shutdown_hook", lambda *_: ev.set())

    while not ev.isSet():
      try:
        tout = wakeup_time - current_time
        if tout > 0:
          ev.wait(timeout = tout)
          current_time = time()
        elif tout < -10:
          # we are late too much; drop 10 ticks
          wakeup_time += 10
          continue
        event.SpamEvent(hookname="timer_hook", 
                        argmap={"tick": self._current_tick}
                       ).enqueue()
        self._current_tick += 1
        wakeup_time += 1
      except KeyboardInterrupt:
        return
      except SystemExit:
        return
      except:
        exported.write_traceback("ticker: ticker hiccupped.")
Esempio n. 2
0
  def runtimer(self):
    """
    This timer thread sleeps for a second, then calls everything
    in the queue with the current tick.
    """
    from time import time
    
    self._current_tick = 0
    wakeup_time = current_time = time()

    import threading
    ev = threading.Event()
    exported.hook_register("shutdown_hook", lambda *_: ev.set())

    while not ev.isSet():
      try:
        tout = wakeup_time - current_time
        if tout > 0:
          ev.wait(timeout = tout)
          current_time = time()
        elif tout < -10:
          # we are late too much; drop 10 ticks
          wakeup_time += 10
          continue
        event.SpamEvent(hookname="timer_hook", 
                        argmap={"tick": self._current_tick}
                       ).enqueue()
        self._current_tick += 1
        wakeup_time += 1
      except KeyboardInterrupt:
        return
      except SystemExit:
        return
      except:
        exported.write_traceback("ticker: ticker hiccupped.")
Esempio n. 3
0
def unload():
  """ Unloads the module by calling any unload/unbind functions."""
  global am
  modutils.unload_commands(commands_dict.keys())
  exported.remove_manager("alias")

  exported.hook_register("user_filter_hook", am.userfilter)
  exported.hook_register("write_hook", am.persist)
Esempio n. 4
0
def unload():
  """ Unloads the module by calling any unload/unbind functions."""
  global am
  modutils.unload_commands(list(commands_dict.keys()))
  exported.remove_manager("alias")

  exported.hook_register("user_filter_hook", am.userfilter)
  exported.hook_register("write_hook", am.persist)
Esempio n. 5
0
def load():
  """ Initializes the module by binding all the commands."""
  global hm
  modutils.load_commands(commands_dict)
  hm = HighlightManager(exported.myengine.getConfigManager())
  exported.add_manager("highlight", hm)

  exported.hook_register("mud_filter_hook", hm.mudfilter, 90)
  exported.hook_register("write_hook", hm.persist)
Esempio n. 6
0
def load():
  """ Initializes the module by binding all the commands."""
  global am
  modutils.load_commands(commands_dict)
  am = AliasManager()
  exported.add_manager("alias", am)

  exported.hook_register("user_filter_hook", am.userfilter, 20)
  exported.hook_register("write_hook", am.persist)
Esempio n. 7
0
def load():
  """ Initializes the module by binding all the commands."""
  global gm
  modutils.load_commands(commands_dict)
  gm = GagManager()
  exported.add_manager("gag", gm)

  exported.hook_register("mud_filter_hook", gm.mudfilter, 50)
  exported.hook_register("write_hook", gm.persist)
Esempio n. 8
0
def load():
    """ Initializes the module by binding all the commands."""
    global gm
    modutils.load_commands(commands_dict)
    gm = GagManager()
    exported.add_manager("gag", gm)

    exported.hook_register("mud_filter_hook", gm.mudfilter, 50)
    exported.hook_register("write_hook", gm.persist)
Esempio n. 9
0
def load():
  """ Initializes the module by binding all the commands."""
  global am
  modutils.load_commands(commands_dict)
  am = AliasManager()
  exported.add_manager("alias", am)

  exported.hook_register("user_filter_hook", am.userfilter, 20)
  exported.hook_register("write_hook", am.persist)
Esempio n. 10
0
 def register(self, instance=None):
   if instance is not None:
     for cmd, (func, arguments, argoptions, helptext) in self.instance_methods_commands_dict.iteritems():
       f = types.MethodType(func, instance)
       self.commands_dict[cmd] = (f, arguments, argoptions, helptext)
     for hook_name, func, priority in self.instance_hooks:
       f = types.MethodType(func, instance)
       self.hooks.append((hook_name, f, priority))
   load_commands(self.commands_dict)
   for hook_name, func, priority in self.hooks:
     exported.hook_register(hook_name, func, priority)
Esempio n. 11
0
 def __init__(self):
   base.BaseUI.__init__(self)
   exported.hook_register("shutdown_hook", self.shutdown)
   exported.hook_register("to_user_hook", self.write)
   exported.hook_register("config_change_hook", self.configChangeHandler)
   exported.hook_register("bell_hook", self.bell)
   exported.hook_register("prompt_hook",
     lambda x: self.write( {
       'message': message.Message(x["prompt"], message.MUDDATA, x["session"])
       } ) )
   self.app = wx.App()
   self.window = window()
   self.window.input.Bind(wx.EVT_CHAR_HOOK, self.process)
Esempio n. 12
0
def load():
  """ Initializes the module by binding all the commands."""
  global sm
  modutils.load_commands(commands_dict)
  sm = SpeedwalkManager()
  exported.add_manager("speedwalk", sm)

  exported.hook_register("user_filter_hook", sm.userfilter, 80)
  exported.hook_register("write_hook", sm.persist)

  from lyntin import config
  for mem in exported.get_active_sessions():
    tc = config.BoolConfig("speedwalk", 1, 1,
         "Allows you to turn on and turn off speedwalk handling.")
    exported.add_config("speedwalk", tc, mem)
Esempio n. 13
0
def load():
  """ Initializes the module by binding all the commands."""
  global sm
  modutils.load_commands(commands_dict)
  sm = SubstituteManager()
  exported.add_manager("substitute", sm)

  exported.hook_register("mud_filter_hook", sm.mudfilter, 50)
  exported.hook_register("write_hook", sm.persist)

  from lyntin import config
  for mem in exported.get_active_sessions():
    tc = config.BoolConfig("ignoresubs", 0, 1,
         "Allows you to turn on and turn off substitutions.")
    exported.add_config("ignoresubs", tc, mem)
Esempio n. 14
0
def load():
  """ Initializes the module by binding all the commands."""
  global sm
  modutils.load_commands(commands_dict)
  sm = SpeedwalkManager()
  exported.add_manager("speedwalk", sm)

  exported.hook_register("user_filter_hook", sm.userfilter, 80)
  exported.hook_register("write_hook", sm.persist)

  from lyntin import config
  for mem in exported.get_active_sessions():
    tc = config.BoolConfig("speedwalk", 1, 1,
         "Allows you to turn on and turn off speedwalk handling.")
    exported.add_config("speedwalk", tc, mem)
Esempio n. 15
0
def load():
  """ Initializes the module by binding all the commands."""
  global sm
  modutils.load_commands(commands_dict)
  sm = SubstituteManager()
  exported.add_manager("substitute", sm)

  exported.hook_register("mud_filter_hook", sm.mudfilter, 50)
  exported.hook_register("write_hook", sm.persist)

  from lyntin import config
  for mem in exported.get_active_sessions():
    tc = config.BoolConfig("ignoresubs", 0, 1,
         "Allows you to turn on and turn off substitutions.")
    exported.add_config("ignoresubs", tc, mem)
Esempio n. 16
0
def load():
  """ Initializes the module by binding all the commands."""
  global vm
  modutils.load_commands(commands_dict)
  vm = VariableManager()
  exported.add_manager("variable", vm)

  exported.hook_register("user_filter_hook", vm.userfilter, 10)
  exported.hook_register("user_filter_hook", vm.denestVars, 95)
  exported.hook_register("default_resolver_hook", vm.defaultResolver)
  exported.hook_register("write_hook", vm.persist)
Esempio n. 17
0
def load():
    """ Initializes the module by binding all the commands."""
    global vm
    modutils.load_commands(commands_dict)
    vm = VariableManager()
    exported.add_manager("variable", vm)

    exported.hook_register("user_filter_hook", vm.userfilter, 10)
    exported.hook_register("user_filter_hook", vm.denestVars, 95)
    exported.hook_register("default_resolver_hook", vm.defaultResolver)
    exported.hook_register("write_hook", vm.persist)
Esempio n. 18
0
    def __init__(self):
        """ Initialize the textui."""
        base.BaseUI.__init__(self)
        exported.hook_register("shutdown_hook", self.shutdown)
        exported.hook_register("to_user_hook", self.write)
        exported.hook_register("config_change_hook", self.configChangeHandler)
        exported.hook_register("bell_hook", self.bell)
        self._currcolors = {}
        self._unfinishedcolor = {}

        self._tio = 0
        self._rline = 0
        self._echo = 1

        # grab the stdin stream at once,
        # enabling it's further redirection by another module
        self._stdin = sys.stdin
Esempio n. 19
0
  def __init__(self):
    """ Initialize the textui."""
    base.BaseUI.__init__(self)
    exported.hook_register("shutdown_hook", self.shutdown)
    exported.hook_register("to_user_hook", self.write)
    exported.hook_register("config_change_hook", self.configChangeHandler)
    exported.hook_register("bell_hook", self.bell)
    self._currcolors = {}
    self._unfinishedcolor = {}

    self._tio = 0
    self._rline = 0
    self._echo = 1

    # grab the stdin stream at once,
    # enabling it's further redirection by another module
    self._stdin = sys.stdin
Esempio n. 20
0
def load():
  """ Initializes the module by binding all the commands."""
  global lm
  modutils.load_commands(commands_dict)
  lm = LoggerManager()
  exported.add_manager("logger", lm)

  exported.hook_register("to_mud_hook", lm.tomudfilter, constants.LAST+1)
  exported.hook_register("mud_filter_hook", lm.mudfilter, 30)
  exported.hook_register("prompt_hook", lm.promptfilter, 30)
Esempio n. 21
0
def load():
  """ Initializes the module by binding all the commands."""
  global am, var_module
  modutils.load_commands(commands_dict)
  am = ActionManager()
  exported.add_manager("action", am)

  exported.hook_register("mud_filter_hook", am.mudfilter, 75)
  exported.hook_register("prompt_hook", am.mudfilter, 75)
  exported.hook_register("write_hook", am.persist)
  exported.hook_register("variable_change_hook", am.variableChange)

  from lyntin import config
  for mem in exported.get_active_sessions():
    # we need a separate BoolConfig for each session
    tc = config.BoolConfig("ignoreactions", 0, 1,
         "Allows you to turn off action handling.")
    exported.add_config("ignoreactions", tc, mem)
Esempio n. 22
0
def load():
  """ Initializes the module by binding all the commands."""
  global smm
  modutils.load_commands(commands_dict)
  smm = sowmud.SowmudManager()
  exported.add_manager("sowmud", smm)
  mapper.load()
  
  exported.hook_register("mud_filter_hook", smm.mudfilter, 76)
  exported.hook_register("user_filter_hook", smm.userfilter, 21)
  exported.hook_register("disconnect_hook", smm.reconnect, 50)
Esempio n. 23
0
def load():
    """ Initializes the module by binding all the commands."""
    global am, var_module
    modutils.load_commands(commands_dict)
    am = ActionManager()
    exported.add_manager("action", am)

    exported.hook_register("mud_filter_hook", am.mudfilter, 75)
    exported.hook_register("write_hook", am.persist)
    exported.hook_register("variable_change_hook", am.variableChange)

    from lyntin import config
    for mem in exported.get_active_sessions():
        # we need a separate BoolConfig for each session
        tc = config.BoolConfig("ignoreactions", 0, 1,
                               "Allows you to turn off action handling.")
        exported.add_config("ignoreactions", tc, mem)
Esempio n. 24
0
def load():
    modutils.load_commands(commands_dict)
    exported.hook_register('mud_filter_hook',mud_filter)
Esempio n. 25
0
def load():
#modutils.load_commands(command_dir)
    exported.hook_register('timer_hook',handle_timer)
Esempio n. 26
0
    def __init__(self):
        """ Initializes."""
        base.BaseUI.__init__(self)

        # internal ui queue
        self._event_queue = queue.Queue()

        # map of session -> (bold, foreground, background)
        self._currcolors = {}

        # ses -> string
        self._unfinishedcolor = {}

        self._viewhistory = 0
        self._do_i_echo = 1

        # holds a map of window names -> window references
        self._windows = {}

        # instantiate all the widgets
        self._tk = Tk()
        self._tk.geometry("800x600")

        self.settitle()

        fnt = tkinter.font.Font(family="FixedSys", size=10)

        self._entry = CommandEntry(self._tk,
                                   self,
                                   fg='white',
                                   bg='black',
                                   insertbackground='yellow',
                                   font=fnt,
                                   insertwidth='2')
        self._entry.pack(side='bottom', fill='both')

        self._topframe = Frame(self._tk)
        self._topframe.pack(side='top', fill='both', expand=1)

        self._txt = ScrolledText(self._topframe,
                                 fg='white',
                                 bg='black',
                                 font=fnt,
                                 height=20)
        self._txt.pack(side='bottom', fill='both', expand=1)

        self._txt.bind("<KeyPress>", self._ignoreThis)
        self._txtbuffer = ScrolledText(self._topframe,
                                       fg='white',
                                       bg='black',
                                       font=fnt,
                                       height=20)
        self._txtbuffer.bind("<KeyPress-Escape>", self.escape)
        self._txtbuffer.bind("<KeyPress>", self._ignoreThis)

        self._entry.focus_set()
        self._initColorTags()
        self.dequeue()

        exported.hook_register("config_change_hook", self.configChangeHandler)
        exported.hook_register("to_user_hook", self.write)

        # FIXME - fix this explanation.  this is just terrible.
        tc = config.BoolConfig(
            "saveinputhighlight", 0, 1,
            "Allows you to change the behavior of the command entry.  When "
            "saveinputhighlight is off, we discard whatever is on the entry "
            "line.  When it is on, we will retain the contents allowing you "
            "to press the enter key to do whatever you typed again.")
        exported.add_config("saveinputhighlight", tc)

        self._quit = 0
Esempio n. 27
0
def load():
    """Initializes the module by binding all the commands."""
    exported.hook_register("to_user_hook", handle_recv_data)
Esempio n. 28
0
def load():
	exported.hook_register("user_filter_hook", handle_user_filter)
Esempio n. 29
0
def load():
    exported.hook_register("user_filter_hook", handle_user_filter)
Esempio n. 30
0
    def __init__(self):
        base.BaseUI.__init__(self)

        exported.hook_register("startup_hook", startup_hook)
        exported.hook_register("to_user_hook", self.write)
        exported.hook_register("config_change_hook", self.config_changed)
        exported.hook_register("bell_hook", lambda x: sys.stdout.write('\07'))
        exported.hook_register(
            "prompt_hook", lambda x: self.write({
                'message':
                message.Message(x["prompt"], message.MUDDATA, x["session"])
            }))
        exported.hook_register("write_hook", bindings_persist)

        self.unfinished_ = {}

        self.prompt_ = [("", curses.A_NORMAL)]
        self.lines_ = [self.prompt_]
        self.prompt_index_ = 0

        self.running_ = 1

        self.cfg_lazy_ = exported.get_config("curses.lazy")
        self.cfg_maxscrollback_ = exported.get_config("curses.maxscrollback")
        self.cfg_keydebug_ = exported.get_config("curses.keydebug")
        self.cfg_compact_ = exported.get_config("curses.compact")
        self.cfg_echo_ = exported.get_config("mudecho")

        global color_lookup
        self.attr_error_ = color_lookup[exported.get_config(
            "curses.attr.error")]
        self.attr_session_ = color_lookup[exported.get_config(
            "curses.attr.session")]
        self.attr_lyntin_ = color_lookup[exported.get_config(
            "curses.attr.lyntin")]
        self.attr_user_ = color_lookup[exported.get_config("curses.attr.user")]

        self.output_ = os.pipe()  # MUD output signalling pipe
Esempio n. 31
0
 def startup(self):
     exported.hook_register("timer_hook", self.timeUpdate)
 def __init__(self):
     print "kaiui : init"
     base.BaseUI.__init__(self)
     exported.hook_register("to_user_hook", self.write)
Esempio n. 33
0
def load():
    """ Initializes the module by binding all the commands."""
    exported.hook_register("mud_filter_hook", mudfilter)
    modutils.load_commands(commands_dict)
Esempio n. 34
0
def load():
    exported.hook_register("timer_hook", timerget)
    exported.hook_register("mud_filter_hook", look_fortarget)
    modutils.load_commands(command_dic)
Esempio n. 35
0
  def __init__(self):
    base.BaseUI.__init__(self)
    
    exported.hook_register("startup_hook", startup_hook)
    exported.hook_register("to_user_hook", self.write)
    exported.hook_register("config_change_hook", self.config_changed)
    exported.hook_register("bell_hook", lambda x: sys.stdout.write('\07'))
    exported.hook_register("prompt_hook",
      lambda x: self.write( {
        'message': message.Message(x["prompt"], message.MUDDATA, x["session"])
        } ) )
    exported.hook_register("write_hook", bindings_persist)

    self.unfinished_ = {}

    self.prompt_ = [("", curses.A_NORMAL)]
    self.lines_ = [ self.prompt_ ]
    self.prompt_index_ = 0

    self.running_ = 1

    self.cfg_lazy_ = exported.get_config("curses.lazy")
    self.cfg_maxscrollback_ = exported.get_config("curses.maxscrollback")
    self.cfg_keydebug_ = exported.get_config("curses.keydebug")
    self.cfg_compact_ = exported.get_config("curses.compact")
    self.cfg_echo_ = exported.get_config("mudecho")

    global color_lookup
    self.attr_error_= color_lookup[exported.get_config("curses.attr.error")]
    self.attr_session_= color_lookup[exported.get_config("curses.attr.session")]
    self.attr_lyntin_= color_lookup[exported.get_config("curses.attr.lyntin")]
    self.attr_user_= color_lookup[exported.get_config("curses.attr.user")]

    self.output_ = os.pipe()  # MUD output signalling pipe
Esempio n. 36
0
def load():
	exported.hook_register("from_mud_hook", handle_from_mud)
	modutils.load_commands(commands_dict)
	exported.add_help("root.commands.commo", commo_help)
	exported.remove_help("root.commo")
Esempio n. 37
0
def load():
	exported.hook_register("connect_hook", handle_connect)
	exported.hook_register("disconnect_hook", handle_disconnect)
	exported.hook_register("timer_hook", handle_timer)
	exported.hook_register("to_mud_hook", handle_to_mud)
Esempio n. 38
0
def load():
	exported.hook_register("connect_hook", handle_connect)
	exported.hook_register("disconnect_hook", handle_disconnect)
	exported.hook_register("from_mud_hook", handle_from_mud)
Esempio n. 39
0
    def __init__(self):
        """ Initializes."""
        base.BaseUI.__init__(self)

        # internal ui queue
        self._event_queue = Queue.Queue()

        # map of session -> (bold, foreground, background)
        self._currcolors = {}

        # ses -> string
        self._unfinishedcolor = {}

        self._viewhistory = 0
        self._do_i_echo = 1

        # holds a map of window names -> window references
        self._windows = {}

        # instantiate all the widgets
        self._tk = Tk()
        self._tk.geometry("800x600")

        self.settitle()

        if os.name == "posix":
            fnt = tkFont.Font(family="Courier", size=12)
        else:
            fnt = tkFont.Font(family="Fixedsys", size=12)

        self._entry = CommandEntry(
            self._tk, self, fg="white", bg="black", insertbackground="yellow", font=fnt, insertwidth="2"
        )
        self._entry.pack(side="bottom", fill="both")

        self._topframe = Frame(self._tk)
        self._topframe.pack(side="top", fill="both", expand=1)

        self._txt = ScrolledText(self._topframe, fg="white", bg="black", font=fnt, height=20)
        self._txt.pack(side="bottom", fill="both", expand=1)

        self._txt.bind("<KeyPress>", self._ignoreThis)
        self._txtbuffer = ScrolledText(self._topframe, fg="white", bg="black", font=fnt, height=20)
        self._txtbuffer.bind("<KeyPress-Escape>", self.escape)
        self._txtbuffer.bind("<KeyPress>", self._ignoreThis)

        self._entry.focus_set()
        self._initColorTags()
        self.dequeue()

        exported.hook_register("config_change_hook", self.configChangeHandler)
        exported.hook_register("to_user_hook", self.write)

        # FIXME - fix this explanation.  this is just terrible.
        tc = config.BoolConfig(
            "saveinputhighlight",
            0,
            1,
            "Allows you to change the behavior of the command entry.  When "
            "saveinputhighlight is off, we discard whatever is on the entry "
            "line.  When it is on, we will retain the contents allowing you "
            "to press the enter key to do whatever you typed again.",
        )
        exported.add_config("saveinputhighlight", tc)

        self._quit = 0
Esempio n. 40
0
 def startup(self):
   exported.hook_register("timer_hook", self.timeUpdate)
Esempio n. 41
0
def load():
    exported.hook_register('timer_hook',timer)
    exported.hook_register('mud_filter_hook',find_nmes)
Esempio n. 42
0
def load():
    """Initializes the module by binding all the commands."""
    exported.hook_register("net_read_data_filter", handle_recv_data)