Hi Ian,
* Ian Ward <[EMAIL PROTECTED]> wrote:
> Fabian Braennstroem wrote:
>> Hi,
>>
>> * Rebecca Breu <[EMAIL PROTECTED]> wrote:
>>> buttom, put the "main view" inside a Frame or Pile widget. If you can live
>>> without those fancy thin unicode lines, that's not so hard to do. Otherwise
>>> the LineBox widget could help...
>
> LineBox is easy, and vertical lines aren't too difficult:
>
> vline = urwid.SolidFill(u'\u2502')
>
> # put it between two box widgets
> boxcol = urwid.Columns([boxwidget1, ('fixed',1,vline), boxwidget2])
>
> # put it between two flow widgets
> flowcol = urwid.Columns([flowwidget1, ('fixed',1,vline), flowwidget2],
> box_columns=[1])
Thanks!
>
>
>> Thanks! When reading it, I get one more question in mind :-)
>> For an urwid based lfm I would like to set my own
>> keybindings in a vim-like way, e.g. I don't want to use the
>> Up and Down key, but 'j' and 'k' for scrolling to the next
>> line. Is there a urwid specific way to define those
>> keybindings or would be similar to lfm, where I just define
>> a function which goes to the next item in a 'list'!?
>
> That depends on what you want.
>
> Currently the "up", "down", "page up" and "page down" keys are hard
> coded into the ListBox widget and the "up" and "down" keys are hard
> coded into the Pile widget.
>
> You can translate "j" and "k" to "down" and "up" if they aren't handled
> by an edit widget or similar with code like:
>
> # ... part of your main loop
> for k in self.ui.get_input():
> # (not shown) do urwid.is_mouse_event stuff..
> k = self.view.keypress(size, k)
> if k == "j":
> self.view.keypress(size, "down")
> if k == "k":
> self.view.keypress(size, "up")
> # ...
>
> If that's not what you're looking for, would you tell me what behaviour
> you want when the user presses the "up" and "down" keys?
In lfm/curses I can adjust the keybindings for all functions easyly using a
'keytable':
keytable = {
# movement
ord('p'): 'cursor_up',
ord('k'): 'cursor_up',
ord('K'): 'cursor_up2',
ord('P'): 'cursor_up',
curses.KEY_UP: 'cursor_up',
ord('n'): 'cursor_down',
ord('j'): 'cursor_down',
ord('J'): 'cursor_down2',
ord('N'): 'cursor_down',
curses.KEY_DOWN: 'cursor_down',
curses.KEY_PPAGE: 'page_previous',
curses.KEY_BACKSPACE: 'page_previous',
# misc
ord('#'): 'show_size',
ord('s'): 'sort',
ord('i'): 'file_info',
ord('I'): 'file_info',
ord('@'): 'action_on_file',
0xF1: 'special_regards', # special regards
ord('/'): 'find_grep',
ord('T'): 'touch_file',
ord('L'): 'create_link',
0x0C: 'edit_link', # Ctrl-L
0x0F: 'open_shell', # Ctrl-O
...
So it is not only for the directories, rather for every function in lfm and it
would be nice to use such a keytable when using urwid too. As you can see using
'j' and 'k' are just alternatives for the 'up' and 'down' keys, but for a fast
navigation much better (the same counts for 'page_up|down' ...).
Thanks for your help!
Greetings!
Fabian
_______________________________________________
Urwid mailing list
[email protected]
http://lists.excess.org/mailman/listinfo/urwid