make it possible to activate highlighter only for specific file types

In stage 1 we use a glob pattern matching the file name.
Stage 2 (which I will maybe implement some day) might use some additional magic byte sequence for file type detection.
This commit is contained in:
2024-03-25 19:23:24 +01:00
parent 56189f4094
commit 66d6a728cc
4 changed files with 35 additions and 4 deletions

View File

@@ -24,12 +24,13 @@ class LogFileModel:
def __init__(self, file: str, settings: Settings):
self.settings = settings
self._file = os.path.realpath(file)
self._file_name = os.path.basename(self._file)
def highlighters(self):
all_highlighters = Highlighting.read_config(self.settings)
active_highlighters = []
for h in all_highlighters:
if h.is_active():
if h.is_active() and h.file_type_matches(self._file_name):
active_highlighters.append(h)
return active_highlighters