MCPcopy Create free account
hub / github.com/TabViewer/tabview / location_string

Method location_string

tabview/tabview.py:795–819  ·  view source on GitHub ↗

Create (y,x) col_label string. Max 30% of screen width. (y,x) is padded to the max possible length it could be. Label string gets trunc_char appended if it's longer than the allowed width.

(self, yp, xp)

Source from the content-addressed store, hash-verified

793 self.goto_y(self.win_y + self.y + 1)
794
795 def location_string(self, yp, xp):
796 """Create (y,x) col_label string. Max 30% of screen width. (y,x) is
797 padded to the max possible length it could be. Label string gets
798 trunc_char appended if it's longer than the allowed width.
799
800 """
801 yx_str = "({},{}) "
802 label_str = "{},{}"
803 max_y = str(len(self.data))
804 max_x = str(len(self.data[0]))
805 max_yx = yx_str.format(max_y, max_x)
806 max_label = label_str.format('-', max(self.header, key=len))
807 if self.header_offset != self.header_offset_orig:
808 # Hide column labels if header row disabled
809 label = ""
810 max_width = min(int(self.max_x * .3), len(max_yx))
811 else:
812 label = label_str.format('-', self.header[xp])
813 max_width = min(int(self.max_x * .3), len(max_yx + max_label))
814 yx = yx_str.format(yp + 1, xp + 1)
815 pad = " " * (max_width - len(yx) - len(label))
816 all = "{}{}{}".format(yx, label, pad)
817 if len(all) > max_width:
818 all = all[:max_width - 1] + self.trunc_char
819 return all
820
821 def display(self):
822 """Refresh the current display"""

Callers 3

show_cellMethod · 0.95
show_infoMethod · 0.95
displayMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected