Skip to content

Commit

Permalink
Merge pull request #3 from esp-cpp/feat/ansi-logs-and-speedup
Browse files Browse the repository at this point in the history
feat: Allow ANSI in log files; speed up log output
  • Loading branch information
finger563 authored Nov 19, 2024
2 parents b882fe7 + 2a6557c commit bcd29b9
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import re
import serial
import serial.tools.list_ports
from io import StringIO

import threading
import queue
Expand All @@ -26,7 +27,7 @@ def escape_ansi(line):
QDialog,
QFileDialog,
QSplitter,
QTextEdit,
QPlainTextEdit,
QVBoxLayout,
)

Expand All @@ -36,7 +37,6 @@ def escape_ansi(line):
import csv
from tabs import Tabs


class MainWindow(QMainWindow):

from menubar import (
Expand Down Expand Up @@ -108,7 +108,7 @@ def __init_font__(self):

def __get_editor_stylesheet__(self):
return """
QTextEdit {
QPlainTextEdit {
background: rgb(27,27,28); border-color: gray; color: rgb(255, 255, 255);
}
QScrollBar {
Expand All @@ -129,7 +129,7 @@ def __get_editor_stylesheet__(self):
def __init_ui__(self):
QApplication.setStyle(QStyleFactory.create("Cleanlooks"))
self.__init_font__()
self.log_editor = QTextEdit()
self.log_editor = QPlainTextEdit()
self.log_editor.setFont(self.font)
self.log_editor.setStyleSheet(self.__get_editor_stylesheet__())

Expand Down Expand Up @@ -158,7 +158,7 @@ def __init_ui__(self):

self.setStyleSheet("QMainWindow { background-color: rgb(27,27,28); }")

self.output_editor = QTextEdit()
self.output_editor = QPlainTextEdit()
self.output_editor.setFont(self.font)
self.output_editor.setStyleSheet(self.__get_editor_stylesheet__())

Expand Down Expand Up @@ -399,9 +399,10 @@ def __open_raw__(self):
self.plot_tab.setToolTip(path)

with open(path, "r") as csvfile:
self.output(csvfile.read())
csvfile.seek(0, 0) # go back to the beginning
reader = csv.reader(csvfile)
filedata = csvfile.read()
filedata = escape_ansi(filedata)
self.output(filedata)
reader = csv.reader(StringIO(filedata))

# Clear existing plot and set new header
self.__clear_plot__()
Expand Down

0 comments on commit bcd29b9

Please sign in to comment.