highlight matches
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import math
|
||||
import re
|
||||
import threading
|
||||
import time
|
||||
from typing import List
|
||||
from typing import List, Optional
|
||||
|
||||
from PyQt6.QtGui import QBrush, QColor
|
||||
from PyQt6.QtGui import QBrush, QColor, QPen
|
||||
|
||||
from highlight_regex import HighlightRegex
|
||||
from line import Line
|
||||
@@ -12,6 +13,7 @@ from settings import Settings
|
||||
|
||||
|
||||
class LogFileModel:
|
||||
_query_highlight: Optional[HighlightRegex] = None
|
||||
|
||||
def __init__(self, file: str, settings: Settings):
|
||||
self.settings = settings
|
||||
@@ -20,8 +22,9 @@ class LogFileModel:
|
||||
|
||||
self.highlights = [
|
||||
HighlightRegex(
|
||||
r"ERROR",
|
||||
re.compile("ERROR"),
|
||||
brush=QBrush(QColor(220, 112, 122)),
|
||||
pen=QPen(QColor(0, 0, 0)),
|
||||
brush_full_line=QBrush(QColor(255, 112, 122))
|
||||
)
|
||||
]
|
||||
@@ -32,6 +35,18 @@ class LogFileModel:
|
||||
def __str__(self):
|
||||
return self._file
|
||||
|
||||
def get_query_highlight(self):
|
||||
return self._query_highlight
|
||||
|
||||
def set_query_highlight(self, regex: Optional[re.Pattern] = None):
|
||||
if regex:
|
||||
self._query_highlight = HighlightRegex(
|
||||
regex,
|
||||
brush=QBrush(QColor(255, 255, 0))
|
||||
)
|
||||
else:
|
||||
self._query_highlight = None
|
||||
|
||||
def get_tab_name(self):
|
||||
file_name = os.path.basename(self._file)
|
||||
if len(file_name) > 35:
|
||||
|
||||
Reference in New Issue
Block a user