summaryrefslogtreecommitdiff
path: root/src/tabs.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2012-09-26 01:54:20 +0200
committermathieui <mathieui@mathieui.net>2012-09-26 01:54:20 +0200
commit09ff076bc44eed93a570af29e04bdd720ce9569a (patch)
tree72343022025dca4af60c3ad61286a5b154820c71 /src/tabs.py
parent0bd55a27f2f14dd434c828f4a061f366b39dda92 (diff)
downloadpoezio-09ff076bc44eed93a570af29e04bdd720ce9569a.tar.gz
poezio-09ff076bc44eed93a570af29e04bdd720ce9569a.tar.bz2
poezio-09ff076bc44eed93a570af29e04bdd720ce9569a.tar.xz
poezio-09ff076bc44eed93a570af29e04bdd720ce9569a.zip
Rewrite the tab number handling
- Now the tab number is computed instead of assigned and fixed - Added tabs.GapTab to keep the old behaviour - Added a create_gaps option, defaults to true (may change in the future) - If there are gaps before using /set to change the option to false, they will be removed. (this is a preparation for the move_tab command)
Diffstat (limited to 'src/tabs.py')
-rw-r--r--src/tabs.py23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/tabs.py b/src/tabs.py
index 60f98abc..327ecfba 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -99,7 +99,6 @@ STATE_PRIORITY = {
}
class Tab(object):
- number = 0
tab_core = None
def __init__(self):
self.input = None
@@ -109,8 +108,6 @@ class Tab(object):
self._state = 'normal'
self.need_resize = False
- self.nb = Tab.number
- Tab.number += 1
self.need_resize = False
self.key_func = {} # each tab should add their keys in there
# and use them in on_input
@@ -124,6 +121,15 @@ class Tab(object):
return Tab.tab_core
@property
+ def nb(self):
+ log.debug("COUCOU TABS")
+ for index, tab in enumerate(self.core.tabs):
+ log.debug("%s", tab.__class__)
+ if tab == self:
+ return index
+ return len(self.core.tabs)
+
+ @property
def tab_win(self):
if not Tab.tab_core:
Tab.tab_core = singleton.Singleton(core.Core)
@@ -363,6 +369,17 @@ class Tab(object):
def __del__(self):
log.debug('------ Closing tab %s', self.__class__.__name__)
+class GapTab(Tab):
+
+ def __bool__(self):
+ return False
+
+ def __len__(self):
+ return 0
+
+ def get_name(self):
+ return ''
+
class ChatTab(Tab):
"""
A tab containing a chat of any type.