rename again buffers→windows and Alt+←→ to switch tabs

This commit is contained in:
louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 2010-11-22 01:39:37 +00:00
parent a1c4b35b57
commit 30405d1fbb
3 changed files with 45 additions and 39 deletions

View file

@ -133,10 +133,12 @@ class Core(object):
"KEY_NPAGE": self.scroll_page_down,
"KEY_F(5)": self.rotate_rooms_left,
"^P": self.rotate_rooms_left,
'kLFT3': self.rotate_rooms_left,
"KEY_F(6)": self.rotate_rooms_right,
"^N": self.rotate_rooms_right,
'kRIT3': self.rotate_rooms_right,
"KEY_F(7)": self.shrink_information_win,
"KEY_F(8)": self.grow_information_win,
"^N": self.rotate_rooms_right,
"KEY_RESIZE": self.call_for_resize,
'M-e': self.go_to_important_room,
'M-r': self.go_to_roster,

View file

@ -15,7 +15,7 @@
# along with Poezio. If not, see <http://www.gnu.org/licenses/>.
"""
a Tab object is a way to organize various Buffers (see buffers.py)
a Tab object is a way to organize various Windows (see windows.py)
around the screen at once.
A tab is then composed of multiple Buffer.
Each Tab object has different refresh() and resize() methods, defining how its
@ -28,7 +28,7 @@ MIN_HEIGHT = 16
import logging
log = logging.getLogger(__name__)
import buffers
import windows
import theme
import curses
import difflib
@ -145,9 +145,9 @@ class InfoTab(Tab):
"""
def __init__(self, core, name):
Tab.__init__(self, core)
self.tab_win = buffers.GlobalInfoBar(1, self.width, self.height-2, 0, self.core.stdscr, self.visible)
self.text_win = buffers.TextWin(self.height-2, self.width, 0, 0, self.core.stdscr, self.visible)
self.input = buffers.Input(1, self.width, self.height-1, 0, self.core.stdscr, self.visible)
self.tab_win = windows.GlobalInfoBar(1, self.width, self.height-2, 0, self.core.stdscr, self.visible)
self.text_win = windows.TextWin(self.height-2, self.width, 0, 0, self.core.stdscr, self.visible)
self.input = windows.Input(1, self.width, self.height-1, 0, self.core.stdscr, self.visible)
self.name = name
self.color_state = theme.COLOR_TAB_NORMAL
@ -196,6 +196,10 @@ class InfoTab(Tab):
def on_close(self):
return
class ChatTab(Tab):
"""
"""
class MucTab(Tab):
"""
The tab containing a multi-user-chat room.
@ -204,14 +208,14 @@ class MucTab(Tab):
def __init__(self, core, room):
Tab.__init__(self, core)
self._room = room
self.topic_win = buffers.Topic(1, self.width, 0, 0, self.core.stdscr, self.visible)
self.text_win = buffers.TextWin(self.height-4-self.core.information_win_size, (self.width//10)*9, 1, 0, self.core.stdscr, self.visible)
self.v_separator = buffers.VerticalSeparator(self.height-3, 1, 1, 9*(self.width//10), self.core.stdscr, self.visible)
self.user_win = buffers.UserList(self.height-3, (self.width//10), 1, 9*(self.width//10)+1, self.core.stdscr, self.visible)
self.info_header = buffers.MucInfoWin(1, (self.width//10)*9, self.height-3-self.core.information_win_size, 0, self.core.stdscr, self.visible)
self.info_win = buffers.TextWin(self.core.information_win_size, (self.width//10)*9, self.height-2-self.core.information_win_size, 0, self.core.stdscr, self.visible)
self.tab_win = buffers.GlobalInfoBar(1, self.width, self.height-2, 0, self.core.stdscr, self.visible)
self.input = buffers.MessageInput(1, self.width, self.height-1, 0, self.core.stdscr, self.visible)
self.topic_win = windows.Topic(1, self.width, 0, 0, self.core.stdscr, self.visible)
self.text_win = windows.TextWin(self.height-4-self.core.information_win_size, (self.width//10)*9, 1, 0, self.core.stdscr, self.visible)
self.v_separator = windows.VerticalSeparator(self.height-3, 1, 1, 9*(self.width//10), self.core.stdscr, self.visible)
self.user_win = windows.UserList(self.height-3, (self.width//10), 1, 9*(self.width//10)+1, self.core.stdscr, self.visible)
self.info_header = windows.MucInfoWin(1, (self.width//10)*9, self.height-3-self.core.information_win_size, 0, self.core.stdscr, self.visible)
self.info_win = windows.TextWin(self.core.information_win_size, (self.width//10)*9, self.height-2-self.core.information_win_size, 0, self.core.stdscr, self.visible)
self.tab_win = windows.GlobalInfoBar(1, self.width, self.height-2, 0, self.core.stdscr, self.visible)
self.input = windows.MessageInput(1, self.width, self.height-1, 0, self.core.stdscr, self.visible)
def resize(self):
"""
@ -330,11 +334,11 @@ class PrivateTab(Tab):
def __init__(self, core, room):
Tab.__init__(self, core)
self._room = room
self.text_win = buffers.TextWin(self.height-3-self.core.information_win_size, self.width, 0, 0, self.core.stdscr, self.visible)
self.info_header = buffers.PrivateInfoWin(1, self.width, self.height-3-self.core.information_win_size, 0, self.core.stdscr, self.visible)
self.info_win = buffers.TextWin(self.core.information_win_size, self.width, self.height-2-self.core.information_win_size, 0, self.core.stdscr, self.visible)
self.tab_win = buffers.GlobalInfoBar(1, self.width, self.height-2, 0, self.core.stdscr, self.visible)
self.input = buffers.MessageInput(1, self.width, self.height-1, 0, self.core.stdscr, self.visible)
self.text_win = windows.TextWin(self.height-3-self.core.information_win_size, self.width, 0, 0, self.core.stdscr, self.visible)
self.info_header = windows.PrivateInfoWin(1, self.width, self.height-3-self.core.information_win_size, 0, self.core.stdscr, self.visible)
self.info_win = windows.TextWin(self.core.information_win_size, self.width, self.height-2-self.core.information_win_size, 0, self.core.stdscr, self.visible)
self.tab_win = windows.GlobalInfoBar(1, self.width, self.height-2, 0, self.core.stdscr, self.visible)
self.input = windows.MessageInput(1, self.width, self.height-1, 0, self.core.stdscr, self.visible)
def resize(self):
Tab.resize(self)
@ -418,12 +422,12 @@ class RosterInfoTab(Tab):
self.name = "Roster"
roster_width = self.width//2
info_width = self.width-roster_width-1
self.v_separator = buffers.VerticalSeparator(self.height-2, 1, 0, roster_width, self.core.stdscr, self.visible)
self.tab_win = buffers.GlobalInfoBar(1, self.width, self.height-2, 0, self.core.stdscr, self.visible)
self.info_win = buffers.TextWin(self.height-2, info_width, 0, roster_width+1, self.core.stdscr, self.visible)
self.roster_win = buffers.RosterWin(self.height-2-3, roster_width, 0, 0, self.core.stdscr, self.visible)
self.contact_info_win = buffers.ContactInfoWin(3, roster_width, self.height-2-3, 0, self.core.stdscr, self.visible)
self.default_help_message = buffers.HelpText(1, self.width, self.height-1, 0, self.core.stdscr, self.visible, "Enter commands with “/”. “o”: toggle offline show")
self.v_separator = windows.VerticalSeparator(self.height-2, 1, 0, roster_width, self.core.stdscr, self.visible)
self.tab_win = windows.GlobalInfoBar(1, self.width, self.height-2, 0, self.core.stdscr, self.visible)
self.info_win = windows.TextWin(self.height-2, info_width, 0, roster_width+1, self.core.stdscr, self.visible)
self.roster_win = windows.RosterWin(self.height-2-3, roster_width, 0, 0, self.core.stdscr, self.visible)
self.contact_info_win = windows.ContactInfoWin(3, roster_width, self.height-2-3, 0, self.core.stdscr, self.visible)
self.default_help_message = windows.HelpText(1, self.width, self.height-1, 0, self.core.stdscr, self.visible, "Enter commands with “/”. “o”: toggle offline show")
self.input = self.default_help_message
self.set_color_state(theme.COLOR_TAB_NORMAL)
@ -489,7 +493,7 @@ class RosterInfoTab(Tab):
'/' is pressed, we enter "input mode"
"""
curses.curs_set(1)
self.input = buffers.CommandInput(1, self.width, self.height-1, 0, self.default_help_message, self.visible, "", self.reset_help_message, self.execute_slash_command)
self.input = windows.CommandInput(1, self.width, self.height-1, 0, self.default_help_message, self.visible, "", self.reset_help_message, self.execute_slash_command)
self.input.do_command("/") # we add the slash
def reset_help_message(self, _=None):
@ -549,7 +553,7 @@ class RosterInfoTab(Tab):
in it.
"""
curses.curs_set(1)
self.input = buffers.CommandInput(1, self.width, self.height-1, 0, self.default_help_message, self.visible, "[Search]", self.on_search_terminate, self.on_search_terminate, self.set_roster_filter)
self.input = windows.CommandInput(1, self.width, self.height-1, 0, self.default_help_message, self.visible, "[Search]", self.on_search_terminate, self.on_search_terminate, self.set_roster_filter)
return True
def set_roster_filter(self, txt):
@ -576,12 +580,12 @@ class ConversationTab(Tab):
self._text_buffer = text_buffer
self.color_state = theme.COLOR_TAB_NORMAL
self._name = jid # a conversation tab is linked to one specific full jid OR bare jid
self.text_win = buffers.TextWin(self.height-4-self.core.information_win_size, self.width, 1, 0, self.core.stdscr, self.visible)
self.upper_bar = buffers.ConversationStatusMessageWin(1, self.width, 0, 0, self.core.stdscr, self.visible)
self.info_header = buffers.ConversationInfoWin(1, self.width, self.height-3-self.core.information_win_size, 0, self.core.stdscr, self.visible)
self.info_win = buffers.TextWin(self.core.information_win_size, self.width, self.height-2-self.core.information_win_size, 0, self.core.stdscr, self.visible)
self.tab_win = buffers.GlobalInfoBar(1, self.width, self.height-2, 0, self.core.stdscr, self.visible)
self.input = buffers.MessageInput(1, self.width, self.height-1, 0, self.core.stdscr, self.visible)
self.text_win = windows.TextWin(self.height-4-self.core.information_win_size, self.width, 1, 0, self.core.stdscr, self.visible)
self.upper_bar = windows.ConversationStatusMessageWin(1, self.width, 0, 0, self.core.stdscr, self.visible)
self.info_header = windows.ConversationInfoWin(1, self.width, self.height-3-self.core.information_win_size, 0, self.core.stdscr, self.visible)
self.info_win = windows.TextWin(self.core.information_win_size, self.width, self.height-2-self.core.information_win_size, 0, self.core.stdscr, self.visible)
self.tab_win = windows.GlobalInfoBar(1, self.width, self.height-2, 0, self.core.stdscr, self.visible)
self.input = windows.MessageInput(1, self.width, self.height-1, 0, self.core.stdscr, self.visible)
def resize(self):
Tab.resize(self)

View file

@ -15,11 +15,10 @@
# along with Poezio. If not, see <http://www.gnu.org/licenses/>.
"""
Define all the buffers.
A buffer is a little part of the screen, for example the input buffer,
the text bufferr, the roster buffer, etc.
A Tab (see tab.py) is composed of multiple Buffers
A buffer can also be called Window, even if it's not prefered.
Define all the windows.
A window is a little part of the screen, for example the input window,
the text window, the roster window, etc.
A Tab (see tab.py) is composed of multiple Windows
"""
from gettext import (bindtextdomain, textdomain, bind_textdomain_codeset,
@ -608,7 +607,7 @@ class TextWin(Win):
class HelpText(Win):
"""
A buffer just displaying a read-only message.
A Window just displaying a read-only message.
Usually used to replace an Input when the tab is in
command mode.
"""
@ -990,6 +989,7 @@ class MessageInput(Input):
def __init__(self, height, width, y, x, stdscr, visible):
Input.__init__(self, height, width, y, x, stdscr, visible)
self.last_completion = None
self.histo_pos = 0
self.key_func["KEY_UP"] = self.key_up
self.key_func["M-A"] = self.key_up