Code: Select all
--- /home/one/.config/cudatext/py/cuda_breadcrumbs/source_breadcrumbs.py
+++ /home/one/.config/cudatext/py/cuda_breadcrumbs/breadcrumbs.py
@@ -19,6 +19,9 @@
fn_config = os.path.join(dir_settings, 'plugins.ini')
OPT_SEC = 'breadcrumbs'
+#20230612
+opt_show_bar = False
+#20230612
opt_position_bottom = True
opt_root_dir_source = [0]
opt_show_root_parents = True
@@ -36,6 +39,10 @@
PROJECT_DIR = None
USER_DIR = os.path.expanduser('~')
+#20230612
+#SHOW_BAR = False
+#20230612
+
SHOW_BAR = True
SHOW_CODE = False
@@ -45,6 +52,7 @@
def bool_to_str(v): return '1' if v else '0'
+
def str_to_bool(s): return s=='1'
def hide_tree(tag='', info=''):
@@ -97,7 +105,13 @@
app_proc(PROC_SET_EVENTS, _ev_str)
def _load_config(self):
+
+
global PROJECT_DIR
+#20230612
+ global SHOW_BAR
+ global opt_show_bar
+#20230612
global opt_position_bottom
global opt_root_dir_source
global opt_show_root_parents
@@ -120,7 +134,10 @@
except Exception:
print(_('NOTE: Breadcrumbs - Unable to parse option value: "root_dir_source" should be '
'a comma-separated string of integers 0-2'))
-
+#20230612
+ opt_show_bar = str_to_bool(ini_read(fn_config, OPT_SEC, 'show_bar', '1'))
+ SHOW_BAR = opt_show_bar
+#20230612
opt_position_bottom = str_to_bool(ini_read(fn_config, OPT_SEC, 'position_bottom', '1'))
opt_show_root_parents = str_to_bool(ini_read(fn_config, OPT_SEC, 'show_root_parents', '1'))
opt_file_sort_type = ini_read(fn_config, OPT_SEC, 'file_sort_type', opt_file_sort_type)
@@ -139,6 +156,11 @@
def config(self):
_root_dir_source_str = ','.join(map(str, opt_root_dir_source))
+#20230612
+# ini_write(fn_config, OPT_SEC, 'show_bar', bool_to_str(opt_position_bottom ) ) !!!
+ ini_write(fn_config, OPT_SEC, 'show_bar', bool_to_str(opt_show_bar) )
+# print(" def config(self): SHOW_BAR 3=",SHOW_BAR, "opt_show_bar=", opt_show_bar)
+#20230612
ini_write(fn_config, OPT_SEC, 'position_bottom', bool_to_str(opt_position_bottom) )
ini_write(fn_config, OPT_SEC, 'root_dir_source', _root_dir_source_str)
ini_write(fn_config, OPT_SEC, 'show_root_parents', bool_to_str(opt_show_root_parents) )
@@ -155,11 +177,16 @@
file_open(fn_config)
def on_caret(self, ed_self):
+
_callback = "module=cuda_breadcrumbs;cmd=_update_callback;"
timer_proc(TIMER_START_ONE, _callback, 500, tag=str(ed_self.h))
def on_open(self, ed_self):
+ #20230612
+
+# print("КТ on_open ed_self=", ed_self,", SHOW_BAR=",SHOW_BAR)
+ #20230612
self._opened_h_eds.add(ed_self.get_prop(PROP_HANDLE_PRIMARY))
self._opened_h_eds.add(ed_self.get_prop(PROP_HANDLE_SECONDARY))
@@ -169,11 +196,18 @@
b.on_fn_change()
def on_save(self, ed_self):
+ #20230612
+# print("КТ on_save")
+ #20230612
breads = self._get_breads(ed_self)
for b in breads:
b.on_fn_change()
def on_focus(self, ed_self):
+ #20230612
+# print("КТ on_focus")
+ #20230612
+
if ed_self.h not in self._opened_h_eds:
return # ignore `on_focus` that happens before `on_open`
@@ -188,6 +222,9 @@
def on_state(self, ed_self, state):
# tree changed
+ #20230612
+# print("КТ on_state")
+ #20230612
if state == APPSTATE_THEME_UI:
Colors.update()
for bread in self._ed_uis.values():
@@ -220,6 +257,9 @@
def on_close(self, ed_self):
+#20230612
+# print("КТ on_close")
+#20230612
h_ed0 = ed_self.get_prop(PROP_HANDLE_PRIMARY)
h_ed1 = ed_self.get_prop(PROP_HANDLE_SECONDARY)
b0 = self._ed_uis.pop(h_ed0, None)
@@ -233,12 +273,18 @@
def on_cell_click(self, id_dlg, id_ctl, data='', info=''):
# info: "<cell_ind>:<h_ed>"
+#20230612
+# print("КТ on_cell_click")
+#20230612
cell_ind, h_ed = map(int, info.split(':'))
bread = self._ed_uis[h_ed]
bread.on_click(cell_ind)
# cmd
def toggle_vis(self):
+#20230612
+# print("КТ toggle_vis global SHOW_BAR")
+#20230612
global SHOW_BAR
SHOW_BAR = not SHOW_BAR
@@ -254,22 +300,34 @@
# cmd
def show_tree(self):
+#20230612
+# print("КТ show_tree")
+#20230612
breads = self._get_breads(ed)
breads[0].show_file_tree()
# cmd
def show_code_tree(self):
+#20230612
+# print("КТ show_code_tree")
+#20230612
breads = self._get_breads(ed)
breads[0].show_code_tree()
def _update_callback(self, tag='', info=''):
+#20230612
+# print("КТ _update_callback")
+#20230612
h_ed = int(tag)
if h_ed == ed.get_prop(PROP_HANDLE_SELF):
self._update(ed)
def _update(self, ed_self):
+#20230612
+# print("КТ _update")
+#20230612
if not SHOW_BAR:
return
@@ -278,6 +336,9 @@
b.update()
def _get_breads(self, ed_self, check_files=False):
+#20230612
+# print("_get_breads")
+#20230612
""" returns tuple of Breads in tab; usually one, two on split tab with two files
"""
h_ed = ed_self.get_prop(PROP_HANDLE_SELF)
@@ -321,9 +382,15 @@
@property
def current(self):
+#20230612
+# print("current")
+#20230612
return self._ed_uis.get(ed.get_prop(PROP_HANDLE_SELF))
def print_breads(self):
+#20230612
+# print("print_breads")
+#20230612
for h_ed,bread in self._ed_uis.items():
print(f'* bread: {h_ed:_}: {bread.ed} - {bread.ed.get_filename()}')
@@ -333,7 +400,22 @@
_tree = None
+#20230612
+ #Command._load_config(self) "NameError: name 'self' is not defined
+ global SHOW_BAR
+ #global SHOW_BAR
+ #_load_config(self) #NameError: name '_load_config' is not defined
+ #Command._load_config(self) # NameError: name 'self' is not defined
+ print("КТ _class Bread: SHOW_BAR=", SHOW_BAR)
+#20230612
+
def __init__(self, ed_self, is_visible):
+ #20230612
+ global SHOW_BAR
+# Command._load_config(self)
+# print("class Bread: def __init__(, SHOW_BAR=", SHOW_BAR, "is_visible=", is_visible)
+ #20230612
+
_h_ed = ed_self.get_prop(PROP_HANDLE_SELF)
self.ed = Editor(_h_ed) if ed_self is ed else ed_self
self.fn = self.ed.get_filename(options="*")
@@ -360,6 +442,11 @@
@property
def tree(self):
+#20230612
+ global SHOW_BAR
+# Command._load_config(self)
+# print("class Bread: def tree(self), SHOW_BAR=", SHOW_BAR, "is_visible=", is_visible)
+#20230612
if Bread._tree is None:
from .dlg import TreeDlg
@@ -375,6 +462,11 @@
return Bread._tree
def _add_ui(self):
+#20230612
+ global SHOW_BAR
+# Command._load_config(self)
+# print("class Bread: _add_ui(self), SHOW_BAR=", SHOW_BAR, "self=", self)
+#20230612
self.hparent = self.ed.get_prop(PROP_HANDLE_PARENT)
self.n_sb = dlg_proc(self.hparent, DLG_CTL_ADD, 'statusbar')
self.h_sb = dlg_proc(self.hparent, DLG_CTL_HANDLE, index=self.n_sb)
@@ -392,11 +484,22 @@
def reset(self):
+#20230612
+ global SHOW_BAR
+# Command._load_config(self)
+# print("class Bread: def reset(self), SHOW_BAR=", SHOW_BAR, "self=", self)
+#20230612
self._path_items = []
self._code_items = []
statusbar_proc(self.h_sb, STATUSBAR_DELETE_ALL)
def set_visible(self, vis):
+#20230612
+ global SHOW_BAR
+# Command._load_config(self)
+# print("class Bread: set_visible(self, vis), SHOW_BAR=", SHOW_BAR, "vis=", is_vis) NameError: name 'is_vis' is not defined
+# print("class Bread: set_visible(self, vis), SHOW_BAR=", SHOW_BAR, "vis=", vis)
+#20230612
self.is_visible = vis
if self.hparent is not None:
dlg_proc(self.hparent, DLG_CTL_PROP_SET, index=self.n_sb, prop={'vis': vis})
Там много лишнего - отладочную печать еще не всю убрал.