Add syntax highlighting to previews.

This commit is contained in:
Dan Helfman
2026-05-20 21:00:16 -07:00
parent 9310b42d9f
commit 9be1698762
2 changed files with 4 additions and 2 deletions
+1 -1
View File
@@ -70,7 +70,7 @@ def get_archive_files(config, repository, archive_name, list_path=None):
)
READLINES_HINT_BYTES = 1000
READLINES_HINT_BYTES = 2000
def get_archive_file_content(config, repository, archive_name, file_path):
+3 -1
View File
@@ -6,6 +6,7 @@ import logging
import borgmatic.actions.browse.controller
import rich.syntax
import rich.text
import textual._context
import textual.app
@@ -129,7 +130,8 @@ def load_file_preview(browse_app, file_preview, config, repository, archive_name
file_content = borgmatic.actions.browse.controller.get_archive_file_content(config, repository, archive_name, file_path)
browse_app.call_from_thread(timer.stop)
browse_app.call_from_thread(file_preview.update, file_content)
syntax_lexer = rich.syntax.Syntax.guess_lexer(file_path, file_content)
browse_app.call_from_thread(file_preview.update, rich.syntax.Syntax(file_content, syntax_lexer))
OPTION_LIST_BINDINGS = textual.widgets.OptionList.BINDINGS + [