Wrap text in status bar
This commit is contained in:
parent
99ad0407b8
commit
360ce780ae
@ -15,9 +15,11 @@ class Command_prompt(Label):
|
|||||||
# insert mode
|
# insert mode
|
||||||
self.insert=False
|
self.insert=False
|
||||||
|
|
||||||
|
# width of a letter
|
||||||
|
self.char_width=9
|
||||||
|
|
||||||
# cursor position
|
# cursor position
|
||||||
self.cursor=0
|
self.cursor=0
|
||||||
self.cursor_width=9
|
|
||||||
|
|
||||||
# the text, with no color information
|
# the text, with no color information
|
||||||
self.raw_text=""
|
self.raw_text=""
|
||||||
@ -41,7 +43,7 @@ class Command_prompt(Label):
|
|||||||
Rectangle(pos=self.pos,size=self.size)
|
Rectangle(pos=self.pos,size=self.size)
|
||||||
# cursor
|
# cursor
|
||||||
Color(1,1,1)
|
Color(1,1,1)
|
||||||
Rectangle(pos=(self.pos[0]+self.cursor*self.cursor_width,self.pos[1]),size=(self.cursor_width,self.height))
|
Rectangle(pos=(self.pos[0]+self.cursor*self.char_width,self.pos[1]),size=(self.char_width,self.height))
|
||||||
|
|
||||||
# make text under cursor black
|
# make text under cursor black
|
||||||
if self.cursor<len(self.raw_text):
|
if self.cursor<len(self.raw_text):
|
||||||
@ -247,7 +249,8 @@ class Command_prompt(Label):
|
|||||||
return paths[0][end:]
|
return paths[0][end:]
|
||||||
else:
|
else:
|
||||||
# display in status bar
|
# display in status bar
|
||||||
self.app.status_bar.text=""
|
self.app.status_bar.raw_text=""
|
||||||
for path in paths:
|
for path in paths:
|
||||||
self.app.status_bar.text+="\""+path+"\" "
|
self.app.status_bar.raw_text+="\""+path+"\" "
|
||||||
|
self.app.status_bar.draw()
|
||||||
return common_substr(paths)[end:]
|
return common_substr(paths)[end:]
|
||||||
|
2
cross.py
2
cross.py
@ -266,7 +266,7 @@ class Cross_painter(Widget):
|
|||||||
self.canvas.clear()
|
self.canvas.clear()
|
||||||
self.draw()
|
self.draw()
|
||||||
# report position in status bar
|
# report position in status bar
|
||||||
self.app.status_bar.set_position(" {:05.2f} , {:05.2f}".format(self.selected.pos.x,self.selected.pos.y))
|
self.app.status_bar.set_text(" {:05.2f} , {:05.2f}".format(self.selected.pos.x,self.selected.pos.y))
|
||||||
|
|
||||||
|
|
||||||
# find the cross at position pos
|
# find the cross at position pos
|
||||||
|
1
jam.kv
1
jam.kv
@ -13,6 +13,7 @@
|
|||||||
markup: True
|
markup: True
|
||||||
color: (0,0,0,1)
|
color: (0,0,0,1)
|
||||||
font_name: "RobotoMono-Regular"
|
font_name: "RobotoMono-Regular"
|
||||||
|
font_size: "15px"
|
||||||
|
|
||||||
|
|
||||||
<Command_prompt>:
|
<Command_prompt>:
|
||||||
|
@ -8,8 +8,22 @@ class Status_bar(Label):
|
|||||||
# app is used to share information between widgets
|
# app is used to share information between widgets
|
||||||
self.app=app
|
self.app=app
|
||||||
|
|
||||||
|
# width of a character
|
||||||
|
self.char_width=9
|
||||||
|
|
||||||
|
# unformatted text
|
||||||
|
self.raw_text=""
|
||||||
|
|
||||||
# init Label
|
# init Label
|
||||||
super(Status_bar,self).__init__(**kwargs)
|
super(Status_bar,self).__init__(**kwargs)
|
||||||
|
|
||||||
def set_position(self,string):
|
def set_text(self,string):
|
||||||
self.text=escape_markup(string)
|
self.raw_text=string
|
||||||
|
self.draw()
|
||||||
|
|
||||||
|
def draw(self):
|
||||||
|
# do not wrap
|
||||||
|
if len(self.raw_text)<self.width/self.char_width:
|
||||||
|
self.text=self.raw_text
|
||||||
|
else:
|
||||||
|
self.text=self.raw_text[:int(self.width/self.char_width)]
|
||||||
|
Loading…
Reference in New Issue
Block a user