예제 #1
0
파일: listbox.py 프로젝트: dlobue/urwid
    def __init__(self, body):
        """
        body -- a ListWalker-like object that contains
            widgets to be displayed inside the list box
        """
        if hasattr(body,'get_focus'):
            self.body = body
        else:
            self.body = PollingListWalker(body)

        try:
            connect_signal(self.body, "modified", self._invalidate)
        except NameError:
            # our list walker has no modified signal so we must not
            # cache our canvases because we don't know when our
            # content has changed
            self.render = nocache_widget_render_instance(self)

        # offset_rows is the number of rows between the top of the view
        # and the top of the focused item
        self.offset_rows = 0
        # inset_fraction is used when the focused widget is off the 
        # top of the view.  it is the fraction of the widget cut off 
        # at the top.  (numerator, denominator)
        self.inset_fraction = (0,1)

        # pref_col is the preferred column for the cursor when moving
        # between widgets that use the cursor (edit boxes etc.)
        self.pref_col = 'left'

        # variable for delayed focus change used by set_focus
        self.set_focus_pending = 'first selectable'
        
        # variable for delayed valign change used by set_focus_valign
        self.set_focus_valign_pending = None
예제 #2
0
 def __init__(self):
     """Initialize a screen that directly prints escape codes to an output
     terminal.
     """
     super(Screen, self).__init__()
     self._pal_escape = {}
     signals.connect_signal(self, UPDATE_PALETTE_ENTRY, 
         self._on_update_palette_entry)
     self.colors = 16 # FIXME: detect this
     self.has_underline = True # FIXME: detect this
     self.register_palette_entry( None, 'default','default')
     self._keyqueue = []
     self.prev_input_resize = 0
     self.set_input_timeouts()
     self.screen_buf = None
     self._resized = False
     self.maxrow = None
     self.gpm_mev = None
     self.gpm_event_pending = False
     self.last_bstate = 0
     self._setup_G1_done = False
     self._rows_used = None
     self._cy = 0
     self._started = False
     self.bright_is_bold = os.environ.get('TERM',None) != "xterm"
     self._next_timeout = None
     self._term_output_file = sys.stdout
     self._term_input_file = sys.stdin
     # pipe for signalling external event loops about resize events
     self._resize_pipe_rd, self._resize_pipe_wr = os.pipe()
     fcntl.fcntl(self._resize_pipe_rd, fcntl.F_SETFL, os.O_NONBLOCK)
예제 #3
0
 def __init__(self):
     super(Screen, self).__init__()
     self._pal_escape = {}
     signals.connect_signal(self, UPDATE_PALETTE_ENTRY,
                            self._on_update_palette_entry)
     self.colors = 16  # FIXME: detect this
     self.has_underline = True  # FIXME: detect this
     self.register_palette_entry(None, 'default', 'default')
     self._keyqueue = []
     self.prev_input_resize = 0
     self.set_input_timeouts()
     self.screen_buf = None
     self._resized = False
     self.maxrow = None
     self.gpm_mev = None
     self.gpm_event_pending = False
     self.last_bstate = 0
     self._setup_G1_done = False
     self._rows_used = None
     self._cy = 0
     self._started = False
     self.bright_is_bold = os.environ.get('TERM', None) != "xterm"
     self._next_timeout = None
예제 #4
0
 def __init__(self):
     super(Screen, self).__init__()
     self._pal_escape = {}
     signals.connect_signal(self, UPDATE_PALETTE_ENTRY, 
         self._on_update_palette_entry)
     self.colors = 16 # FIXME: detect this
     self.has_underline = True # FIXME: detect this
     self.register_palette_entry( None, 'default','default')
     self._keyqueue = []
     self.prev_input_resize = 0
     self.set_input_timeouts()
     self.screen_buf = None
     self._resized = False
     self.maxrow = None
     self.gpm_mev = None
     self.gpm_event_pending = False
     self.last_bstate = 0
     self._setup_G1_done = False
     self._rows_used = None
     self._cy = 0
     self._started = False
     self.bright_is_bold = os.environ.get('TERM',None) != "xterm"
     self._next_timeout = None
예제 #5
0
 def connect_signal(self, signal, func):
     #		self.emit("signal_connect", signal, func)
     self.__register_signal(signal, func)
     return signals.connect_signal(signal, func)
예제 #6
0
파일: sushi.py 프로젝트: sushi-irc/nigiri
 def connect_signal(self, signal, func):
     # 		self.emit("signal_connect", signal, func)
     self.__register_signal(signal, func)
     return signals.connect_signal(signal, func)
예제 #7
0
def cmd_dcc(main_window, argv):
    """ /dcc chat <target>
	/dcc send <target> <path>
	/dcc list <type>
	/dcc remove <type> <id>
	"""
    if no_connection():
        return

    if len(argv) < 2:
        print_notification("Usage: /dcc accept|chat|send|list|remove")
        return

    server_tab = tabs.get_server(main_window.current_tab)

    if argv[1] == "send":
        if len(argv) < 4:
            print_notification("Usage: /dcc send <target> <path>")
            return

        connection.sushi.dcc_send(server_tab.name, argv[2], argv[3])
    elif argv[1] == "accept":

        def accepted_cb(time, id, *x):
            if id == int(argv[2]):
                print_notification(_("DCC action with id %(id)d accepted.") % {"id": id})
                signals.disconnect_signal("dcc_send", accepted_cb)

        if len(argv) < 3:
            print_notification("Usage: /dcc accept <id>")
            return

        signals.connect_signal("dcc_send", accepted_cb)
        connection.sushi.dcc_send_accept(int(argv[2]))
    elif argv[1] == "chat":
        pass
    elif argv[1] == "list":
        if len(argv) < 3:
            print_notification("Usage: /dcc list chat|send")
            return

        if argv[2] == "send":
            ids, servers, froms, filenames, sizes, progresses, speeds, statuses = connection.sushi.dcc_sends()

            for i in range(len(ids)):
                print_normal(
                    "#%(id)d: %(filename)s from/to %(from)s [%(server)s]: %(progress)d/%(size)d @ %(speed)d"
                    % {
                        "id": ids[i],
                        "filename": filenames[i],
                        "from": froms[i],
                        "server": servers[i],
                        "progress": progresses[i],
                        "size": sizes[i],
                        "speed": speeds[i],
                    }
                )
        elif argv[2] == "chat":
            pass
    elif argv[1] == "remove":
        if len(argv) < 4:
            print_notification("Usage: /dcc remove <type> <id>")
            return

        if argv[2] == "send":
            connection.sushi.dcc_send_remove(int(argv[3]))
        elif argv[2] == "chat":
            pass
예제 #8
0
def cmd_dcc(main_window, argv):
    """ /dcc chat <target>
	/dcc send <target> <path>
	/dcc list <type>
	/dcc remove <type> <id>
	"""
    if no_connection():
        return

    if len(argv) < 2:
        print_notification("Usage: /dcc accept|chat|send|list|remove")
        return

    server_tab = tabs.get_server(main_window.current_tab)

    if argv[1] == "send":
        if len(argv) < 4:
            print_notification("Usage: /dcc send <target> <path>")
            return

        connection.sushi.dcc_send(server_tab.name, argv[2], argv[3])
    elif argv[1] == "accept":

        def accepted_cb(time, id, *x):
            if id == int(argv[2]):
                print_notification(
                    _("DCC action with id %(id)d accepted.") % {"id": id})
                signals.disconnect_signal("dcc_send", accepted_cb)

        if len(argv) < 3:
            print_notification("Usage: /dcc accept <id>")
            return

        signals.connect_signal("dcc_send", accepted_cb)
        connection.sushi.dcc_send_accept(int(argv[2]))
    elif argv[1] == "chat":
        pass
    elif argv[1] == "list":
        if len(argv) < 3:
            print_notification("Usage: /dcc list chat|send")
            return

        if argv[2] == "send":
            ids, servers, froms, filenames, sizes, progresses, speeds, statuses = connection.sushi.dcc_sends(
            )

            for i in range(len(ids)):
                print_normal(
                    "#%(id)d: %(filename)s from/to %(from)s [%(server)s]: %(progress)d/%(size)d @ %(speed)d"
                    % {
                        "id": ids[i],
                        "filename": filenames[i],
                        "from": froms[i],
                        "server": servers[i],
                        "progress": progresses[i],
                        "size": sizes[i],
                        "speed": speeds[i]
                    })
        elif argv[2] == "chat":
            pass
    elif argv[1] == "remove":
        if len(argv) < 4:
            print_notification("Usage: /dcc remove <type> <id>")
            return

        if argv[2] == "send":
            connection.sushi.dcc_send_remove(int(argv[3]))
        elif argv[2] == "chat":
            pass