parent
60590272c2
commit
9c490a686d
|
@ -625,8 +625,8 @@ class Application(object):
|
||||||
self.highlight_chars(slot.y_offset + count, px-x + w.mode.lmargin, p2.x-x, fg, bg)
|
self.highlight_chars(slot.y_offset + count, px-x + w.mode.lmargin, p2.x-x, fg, bg)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
self.highlight_chars(slot.y_offset + count, px-x + w.mode.lmargin, slot.width, fg, bg)
|
self.highlight_chars(slot.y_offset + count, px-x + w.mode.lmargin, slot.width - 1, fg, bg)
|
||||||
px += slot.width - px + x
|
px += slot.width - px + x - 1
|
||||||
if x + slot.width >= len(w.buffer.lines[y]):
|
if x + slot.width >= len(w.buffer.lines[y]):
|
||||||
x = 0
|
x = 0
|
||||||
y += 1
|
y += 1
|
||||||
|
|
|
@ -27,6 +27,7 @@ class Slot(object):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
class VSlot(Slot):
|
class VSlot(Slot):
|
||||||
|
size = 0
|
||||||
slots = []
|
slots = []
|
||||||
heights = []
|
heights = []
|
||||||
def __init__(self, height, width, y_offset=0, x_offset=0):
|
def __init__(self, height, width, y_offset=0, x_offset=0):
|
||||||
|
@ -45,24 +46,67 @@ class VSlot(Slot):
|
||||||
self.y_offset = y_offset
|
self.y_offset = y_offset
|
||||||
self.x_offset = x_offset
|
self.x_offset = x_offset
|
||||||
percs = self.get_percs()
|
percs = self.get_percs()
|
||||||
heights = [int(self.height * p) for p in percs]
|
self.heights = [int(self.height * p) for p in percs]
|
||||||
assert sum(heights) <= self.height
|
assert sum(self.heights) <= self.height
|
||||||
i = 0
|
i = 0
|
||||||
while sum(heights) < self.height:
|
while sum(self.heights) < self.height:
|
||||||
heights[i] += 1
|
self.heights[i] += 1
|
||||||
i = (i + 1) % self.height
|
i = (i + 1) % self.height
|
||||||
self.window.set_size(self.width, self.height)
|
self.window.set_size(self.width, self.height)
|
||||||
total = 0
|
total = 0
|
||||||
for i in range(0, heights):
|
for i in range(0, self.size):
|
||||||
if self.slots[i] is not None:
|
if self.slots[i] is not None:
|
||||||
(slot, height) = (self.slots[i], heights[i])
|
(slot, height) = (self.slots[i], self.heights[i])
|
||||||
slot.resize(height, width, y_offset + total, x_offset)
|
slot.resize(height, width, y_offset + total, x_offset)
|
||||||
total += height
|
total += height
|
||||||
def set(self, w):
|
|
||||||
|
def add_slot(self):
|
||||||
|
self.size += 1
|
||||||
|
self.slots.append(Slot(self.height, self.width, 0))
|
||||||
|
self.heights.append(0)
|
||||||
|
self.fit_slots()
|
||||||
|
return len(self.slots) - 1
|
||||||
|
def empty_slot(self, i):
|
||||||
|
assert i > -1 and i < len(self.slots), "slot %d does not exist" % i
|
||||||
|
return self.slots[i].is_empty()
|
||||||
|
def unset_slot(self, i):
|
||||||
|
assert i > -1 and i < len(self.slots), "slot %d does not exist" % i
|
||||||
|
old_w = self.slots[i].unset()
|
||||||
|
if old_w is not None:
|
||||||
|
old_b = old_w.buffer
|
||||||
|
if not self.is_buffer_visible(old_b):
|
||||||
|
self.hidden_buffers.insert(0, old_b)
|
||||||
|
if len(old_b.windows) > 1:
|
||||||
|
old_b.remove_window(old_w)
|
||||||
|
|
||||||
|
def set_slot(self, i, b):
|
||||||
|
assert i > -1 and i < len(self.slots), "slot %d does not exist" % i
|
||||||
|
assert b in self.buffers, "buffer %s does not exist" % (b.name())
|
||||||
|
slot = self.slots[i]
|
||||||
|
self.unset_slot(i)
|
||||||
|
|
||||||
|
if b in self.hidden_buffers:
|
||||||
|
self.hidden_buffers.remove(b)
|
||||||
|
if self.is_window_visible(b.windows[0]):
|
||||||
|
app = b.windows[0].application
|
||||||
|
w = window.Window(b, app, height=slot.height, width=slot.width)
|
||||||
|
else:
|
||||||
|
w = b.windows[0]
|
||||||
|
slot.set(w)
|
||||||
|
|
||||||
|
def remove_slot(self, i):
|
||||||
|
assert i > -1 and i < len(self.slots), "slot %d does not exist" % i
|
||||||
|
self.unset_slot(i)
|
||||||
|
del self.slots[i]
|
||||||
|
self.fit_slots()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def set(self, i, w):
|
||||||
self.window = w
|
self.window = w
|
||||||
self.resize(self.height, self.width, self.y_offset, self.x_offset)
|
self.resize(self.height, self.width, self.y_offset, self.x_offset)
|
||||||
w.set_size(self.width, self.height)
|
w.set_size(self.width, self.height)
|
||||||
def unset(self):
|
def unset(self, i):
|
||||||
if not self.is_empty():
|
if not self.is_empty():
|
||||||
old_w = self.window
|
old_w = self.window
|
||||||
self.window = None
|
self.window = None
|
||||||
|
|
Loading…
Reference in New Issue