From e95470f3844b1948808fd5818ba6d0e90c723221 Mon Sep 17 00:00:00 2001 From: OusmBlueNinja Date: Sun, 27 Aug 2023 01:20:53 -0500 Subject: [PATCH] added syntax hilighting nano --- packages/nano.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/nano.py b/packages/nano.py index 6fc84aa..aafa665 100644 --- a/packages/nano.py +++ b/packages/nano.py @@ -1,6 +1,9 @@ #["nano", "packages.nano", ["nano"]] import os +from pygments import highlight +from pygments.lexers import PythonLexer +from pygments.formatters import TerminalFormatter class TextEditor: def __init__(self): @@ -42,9 +45,10 @@ class TextEditor: print("Invalid command.") def display(self): - print("Editing: "+self.file) + print("Editing: " + self.file) for i, line in enumerate(self.lines): - print(f"{i + 1}: {line}", end="") + highlighted_line = highlight(line, PythonLexer(), TerminalFormatter()) + print(f"{i + 1}: {highlighted_line}", end="") def newline(self): self.lines.append("\n")