parent
d3fa803e76
commit
60590272c2
|
@ -793,7 +793,7 @@ class Application(object):
|
|||
# XYZ: we should actually use more of the 'state' variables
|
||||
format = "%s %-18s (%s)--L%d--C%d--%s"
|
||||
status = format % (modflag, name, w.mode.name(), cursor.y+1, cursor.x+1, perc)
|
||||
status = status.ljust(slot.total_width + 1)[:slot.total_width + 1]
|
||||
status = status.ljust(slot.width + 1)[:slot.width + 1]
|
||||
|
||||
self.win.addstr(slot.height + slot.y_offset, 0, status, curses.A_REVERSE)
|
||||
|
||||
|
|
|
@ -2,17 +2,16 @@ import sets
|
|||
import window
|
||||
|
||||
class Slot(object):
|
||||
window = None
|
||||
def __init__(self, height, width, y_offset=0, x_offset=0):
|
||||
self.window = None
|
||||
self.resize(height, width, y_offset, x_offset)
|
||||
def is_empty(self):
|
||||
return self.window is None
|
||||
def resize(self, height, width, y_offset=0, x_offset=0):
|
||||
self.height = height
|
||||
self.total_width = width
|
||||
self.width = width
|
||||
self.y_offset = y_offset
|
||||
self.x_offset = x_offset
|
||||
self.height = height
|
||||
self.width = width
|
||||
self.y_offset = y_offset
|
||||
self.x_offset = x_offset
|
||||
if self.window is not None:
|
||||
self.window.set_size(self.width, self.height)
|
||||
def set(self, w):
|
||||
|
@ -27,6 +26,50 @@ class Slot(object):
|
|||
else:
|
||||
return None
|
||||
|
||||
class VSlot(Slot):
|
||||
slots = []
|
||||
heights = []
|
||||
def __init__(self, height, width, y_offset=0, x_offset=0):
|
||||
self.window = None
|
||||
self.resize(height, width, y_offset, x_offset)
|
||||
def is_empty(self):
|
||||
for slot in self.slots:
|
||||
if not slot.is_empty():
|
||||
return False
|
||||
return True
|
||||
def get_percs(self):
|
||||
return [float(x) / self.height for x in self.heights]
|
||||
def resize(self, height, width, y_offset=0, x_offset=0):
|
||||
self.height = height
|
||||
self.width = width
|
||||
self.y_offset = y_offset
|
||||
self.x_offset = x_offset
|
||||
percs = self.get_percs()
|
||||
heights = [int(self.height * p) for p in percs]
|
||||
assert sum(heights) <= self.height
|
||||
i = 0
|
||||
while sum(heights) < self.height:
|
||||
heights[i] += 1
|
||||
i = (i + 1) % self.height
|
||||
self.window.set_size(self.width, self.height)
|
||||
total = 0
|
||||
for i in range(0, heights):
|
||||
if self.slots[i] is not None:
|
||||
(slot, height) = (self.slots[i], heights[i])
|
||||
slot.resize(height, width, y_offset + total, x_offset)
|
||||
total += height
|
||||
def set(self, w):
|
||||
self.window = w
|
||||
self.resize(self.height, self.width, self.y_offset, self.x_offset)
|
||||
w.set_size(self.width, self.height)
|
||||
def unset(self):
|
||||
if not self.is_empty():
|
||||
old_w = self.window
|
||||
self.window = None
|
||||
return old_w
|
||||
else:
|
||||
return None
|
||||
|
||||
class BufferList(object):
|
||||
def __init__(self, height, width, buffers=()):
|
||||
self.height = height
|
||||
|
|
Loading…
Reference in New Issue