mirror of
https://github.com/borgmatic-collective/borgmatic.git
synced 2026-07-22 02:03:01 +02:00
Add syntax highlighting to previews.
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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 + [
|
||||
|
||||
Reference in New Issue
Block a user