Improved log view usability
This commit is contained in:
parent
6b99c5c0d7
commit
b7bac2d5ae
@ -30,9 +30,15 @@ class LogList(Gtk.ListBox):
|
||||
self.set_selection_mode(Gtk.SelectionMode.NONE)
|
||||
|
||||
def _setup_signals(self):
|
||||
# self.connect("row-activated", sink_call)
|
||||
# self.connect("row-selected", sink_call)
|
||||
...
|
||||
def tggl_row_view(lb, row):
|
||||
frame = row.get_child()
|
||||
revealer = frame.get_children()[0]
|
||||
revealer.set_reveal_child(not revealer.get_reveal_child())
|
||||
|
||||
del frame
|
||||
del revealer
|
||||
|
||||
self.connect("row-activated", tggl_row_view)
|
||||
|
||||
def _subscribe_to_events(self):
|
||||
...
|
||||
@ -40,26 +46,35 @@ class LogList(Gtk.ListBox):
|
||||
def _load_widgets(self):
|
||||
...
|
||||
|
||||
def add_log_entry(self, data: str or dict):
|
||||
message = None
|
||||
def add_log_entry(self, m_type: str, data: str or dict):
|
||||
message = None
|
||||
json_data = None
|
||||
|
||||
if isinstance(data, str):
|
||||
parts = data.split("\n", 2)
|
||||
jsonStr = parts[2]
|
||||
messageStr = json.dumps(json.loads(jsonStr), separators = (',', ':'), indent = 4)
|
||||
json_data = json.loads(jsonStr)
|
||||
messageStr = json.dumps(json_data, separators = (',', ':'), indent = 4)
|
||||
message = f"{parts[0]}\r\n\r\n{messageStr}"
|
||||
|
||||
if isinstance(data, dict):
|
||||
message = json.dumps(data, separators = (',', ':'), indent = 4)
|
||||
json_data = data
|
||||
message = json.dumps(data, separators = (',', ':'), indent = 4)
|
||||
|
||||
box = Gtk.Frame()
|
||||
label = Gtk.Label(label=message)
|
||||
frame = Gtk.Frame()
|
||||
revealer = Gtk.Revealer()
|
||||
label = Gtk.Label(label=message)
|
||||
|
||||
label.set_xalign(0.010)
|
||||
frame.set_label( f"> {m_type}: {json_data['id']}" if "id" in json_data.keys() else f"> {m_type}" )
|
||||
frame.set_label_align(0.010, 0.5)
|
||||
revealer.set_reveal_child(False)
|
||||
|
||||
box.set_label(">")
|
||||
box.set_label_align(0.010, 0.5)
|
||||
revealer.add(label)
|
||||
frame.add(revealer)
|
||||
self.add(frame)
|
||||
|
||||
box.add(label)
|
||||
self.add(box)
|
||||
frame.show_all()
|
||||
|
||||
box.show_all()
|
||||
del message
|
||||
del json_data
|
||||
|
@ -154,8 +154,7 @@ class LSPMessageBox(Gtk.Box):
|
||||
message_size = len(message_str)
|
||||
message = f"Content-Length: {message_size}\r\n\r\n{message_str}"
|
||||
|
||||
self.get_parent().log_list.add_log_entry(message)
|
||||
event_system.subscribe("add-log-entry", message)
|
||||
self.get_parent().log_list.add_log_entry("Client Message", message)
|
||||
|
||||
with self.write_lock:
|
||||
self.lsp_process.stdin.write( message.encode("utf-8") )
|
||||
@ -261,7 +260,7 @@ class LSPMessageBox(Gtk.Box):
|
||||
GLib.idle_add(self.handle_lsp_response, response_id, lsp_result)
|
||||
|
||||
def handle_lsp_response(self, id: int, lsp_result: {}):
|
||||
self.get_parent().log_list.add_log_entry(lsp_result)
|
||||
self.get_parent().log_list.add_log_entry("LSP Response Message", lsp_result)
|
||||
|
||||
keys = lsp_result.keys()
|
||||
if "error" in keys:
|
||||
|
Loading…
Reference in New Issue
Block a user