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

@@ -25,6 +25,7 @@ class Highlighting:
is_regex = session.getboolean(section, "is-regex", fallback=False)
line_background_color = session.get(section, "line.background.color", fallback="None")
hit_background_color = session.get(section, "hit.background.color", fallback="None")
activated_for_file_type = session.get(section, "activated-for-file-type", fallback="*")
try:
highlight = HighlightRegex(
@@ -33,7 +34,8 @@ class Highlighting:
is_regex=is_regex,
hit_background_color=hit_background_color,
line_background_color=line_background_color,
active=active
active=active,
activated_for_file_type=activated_for_file_type
)
result.append(highlight)
except:
@@ -57,6 +59,7 @@ class Highlighting:
settings.session.set(section, "is-regex", str(highlighter.is_regex))
settings.session.set(section, "line.background.color", highlighter.line_background_color)
settings.session.set(section, "hit.background.color", highlighter.hit_background_color)
settings.session.set(section, "activated-for-file-type", highlighter.activated_for_file_type)
@staticmethod
def remove_highlighting_sections(settings: Settings):