fixed dumb status bar bug and other stuff
--HG-- branch : pmacs2
This commit is contained in:
parent
298d011154
commit
97069f41a0
|
@ -141,10 +141,13 @@ class Application(object):
|
||||||
self.methods[obj.name] = obj
|
self.methods[obj.name] = obj
|
||||||
|
|
||||||
# window/slot height/width
|
# window/slot height/width
|
||||||
height = self.y - 2
|
height = self.y - 1
|
||||||
#width = self.x - 1
|
|
||||||
width = self.x
|
width = self.x
|
||||||
|
|
||||||
|
# buffer list stuff
|
||||||
|
self.bufferlist = bufferlist.BufferList(height, width)
|
||||||
|
self.active_slot = 0
|
||||||
|
|
||||||
# run user custom code here
|
# run user custom code here
|
||||||
self.rcerror = None
|
self.rcerror = None
|
||||||
self.loadrc()
|
self.loadrc()
|
||||||
|
@ -158,9 +161,6 @@ class Application(object):
|
||||||
if self.rcerror:
|
if self.rcerror:
|
||||||
buffers.insert(0, buffer.DataBuffer('*RcError*', self.rcerror))
|
buffers.insert(0, buffer.DataBuffer('*RcError*', self.rcerror))
|
||||||
|
|
||||||
self.bufferlist = bufferlist.BufferList(height, width)
|
|
||||||
self.active_slot = 0
|
|
||||||
|
|
||||||
# build windows for our buffers
|
# build windows for our buffers
|
||||||
for b in buffers:
|
for b in buffers:
|
||||||
if b.name() == '*Console*':
|
if b.name() == '*Console*':
|
||||||
|
@ -168,7 +168,7 @@ class Application(object):
|
||||||
else:
|
else:
|
||||||
window.Window(b, self, mode_name=init_mode)
|
window.Window(b, self, mode_name=init_mode)
|
||||||
self.bufferlist.add_buffer(b)
|
self.bufferlist.add_buffer(b)
|
||||||
self.bufferlist.set_slot(0, buffers[0])
|
self.bufferlist.set_slot(self.active_slot, buffers[0])
|
||||||
|
|
||||||
# see if the user has requested that we go to a particular line
|
# see if the user has requested that we go to a particular line
|
||||||
if jump_to_line:
|
if jump_to_line:
|
||||||
|
@ -308,8 +308,8 @@ class Application(object):
|
||||||
self.mini_prompt = prompt
|
self.mini_prompt = prompt
|
||||||
self.mini_buffer = minibuffer.MiniBuffer(callback, method, tabber, modename)
|
self.mini_buffer = minibuffer.MiniBuffer(callback, method, tabber, modename)
|
||||||
try:
|
try:
|
||||||
window.Window(self.mini_buffer, self, height=1,
|
w = self.x - 1 - len(self.mini_prompt) - 1
|
||||||
width=self.x-1-len(self.mini_prompt)-1)
|
window.Window(self.mini_buffer, self, height=1, width=w)
|
||||||
self.mini_active = True
|
self.mini_active = True
|
||||||
except minibuffer.MiniBufferError:
|
except minibuffer.MiniBufferError:
|
||||||
self.mini_buffer = None
|
self.mini_buffer = None
|
||||||
|
@ -429,7 +429,7 @@ class Application(object):
|
||||||
n = len(self.bufferlist.slots)
|
n = len(self.bufferlist.slots)
|
||||||
assert n > 0
|
assert n > 0
|
||||||
x = self.x - 1
|
x = self.x - 1
|
||||||
y_sum = self.y - 1 - n
|
y_sum = self.y - n
|
||||||
self.bufferlist.resize(y_sum, x)
|
self.bufferlist.resize(y_sum, x)
|
||||||
|
|
||||||
# exit
|
# exit
|
||||||
|
@ -816,8 +816,7 @@ class Application(object):
|
||||||
# XYZ: we should actually use more of the 'state' variables
|
# XYZ: we should actually use more of the 'state' variables
|
||||||
format = "%s %-18s (%s)--L%d--C%d--%s"
|
format = "%s %-18s (%s)--L%d--C%d--%s"
|
||||||
status = format % (modflag, name, w.mode.name(), cursor.y+1, cursor.x+1, perc)
|
status = format % (modflag, name, w.mode.name(), cursor.y+1, cursor.x+1, perc)
|
||||||
status = status.ljust(slot.width + 1)[:slot.width + 1]
|
status = status.ljust(slot.width)[:slot.width]
|
||||||
|
|
||||||
self.win.addstr(slot.height + slot.y_offset, 0, status, curses.A_REVERSE)
|
self.win.addstr(slot.height + slot.y_offset, 0, status, curses.A_REVERSE)
|
||||||
|
|
||||||
# input bar drawing
|
# input bar drawing
|
||||||
|
|
|
@ -26,61 +26,6 @@ class Slot(object):
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
class Box(object):
|
|
||||||
boxtype = 'box'
|
|
||||||
def _set_hwyx(self, h, w, y, x):
|
|
||||||
self.height = h
|
|
||||||
self.width = w
|
|
||||||
self.y_offset = y
|
|
||||||
self.x_offset = x
|
|
||||||
def __init__(self, h, w, y, x):
|
|
||||||
self._set_hwyx(h, w, y, x)
|
|
||||||
def resize(self, h, w, y, x):
|
|
||||||
self._set_hwyx(h, w, y, x)
|
|
||||||
|
|
||||||
class VBoxes(Box):
|
|
||||||
boxtype = 'vboxes'
|
|
||||||
def __init__(self, h, w, y, x):
|
|
||||||
Box.__init__(self, h, w, y, x)
|
|
||||||
self.boxes = [Box(h, w, y, x)]
|
|
||||||
|
|
||||||
def rescale(self):
|
|
||||||
n = len(self.boxes)
|
|
||||||
|
|
||||||
# first let's divide the new space based on old proportions
|
|
||||||
oldtotal = sum([box.height for box in self.boxes])
|
|
||||||
newtotal = self.height - len(self.boxes) + 1
|
|
||||||
heights = [None] * n
|
|
||||||
for i in range(0, n):
|
|
||||||
heights[i] = int(float(newtotal * self.boxes[i]) / oldtotal)
|
|
||||||
|
|
||||||
# fix any rounding errors
|
|
||||||
_sum = sum([h for h in heights])
|
|
||||||
if _sum < total:
|
|
||||||
adder = 1
|
|
||||||
else:
|
|
||||||
adder = -1
|
|
||||||
for i in range(0, abs(total - _sum)):
|
|
||||||
heights[i % n] += adder
|
|
||||||
|
|
||||||
# now do it!
|
|
||||||
offset = self.y_offset
|
|
||||||
for i in range(0, n):
|
|
||||||
self.boxes[i].resize(heights[i], self.width, offset, self.x_offset)
|
|
||||||
offset += heights[i] + 1
|
|
||||||
|
|
||||||
def resize(self, height, width, y_offset, x_offset):
|
|
||||||
self.height = height
|
|
||||||
self.width = width
|
|
||||||
self.y_offset = y_offset
|
|
||||||
self.x_offset = x_offset
|
|
||||||
self.rescale()
|
|
||||||
|
|
||||||
def split_box(self, n):
|
|
||||||
for box in boxes:
|
|
||||||
b.height = 0
|
|
||||||
self.boxes.extend(boxes)
|
|
||||||
|
|
||||||
class BufferList(object):
|
class BufferList(object):
|
||||||
def __init__(self, height, width, buffers=()):
|
def __init__(self, height, width, buffers=()):
|
||||||
self.height = height
|
self.height = height
|
||||||
|
@ -89,13 +34,14 @@ class BufferList(object):
|
||||||
self.buffer_names = {}
|
self.buffer_names = {}
|
||||||
self.hidden_buffers = []
|
self.hidden_buffers = []
|
||||||
self.slots = []
|
self.slots = []
|
||||||
|
self.mini_height = 1
|
||||||
|
|
||||||
self.add_slot()
|
self.add_slot()
|
||||||
self.fit_slots()
|
self.fit_slots()
|
||||||
for b in buffers:
|
for b in buffers:
|
||||||
self.add_buffer(b)
|
self.add_buffer(b)
|
||||||
def fit_slots(self):
|
def fit_slots(self):
|
||||||
total = self.height - len(self.slots) + 1
|
total = self.height - len(self.slots) + 1 - self.mini_height
|
||||||
heights = [total / len(self.slots)] * len(self.slots)
|
heights = [total / len(self.slots)] * len(self.slots)
|
||||||
for i in range(0, total % len(self.slots)):
|
for i in range(0, total % len(self.slots)):
|
||||||
heights[i] += 1
|
heights[i] += 1
|
||||||
|
|
Loading…
Reference in New Issue