added syntax hilighting nano
This commit is contained in:
parent
d9b34a3f2a
commit
e95470f384
@ -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):
|
||||
@ -44,7 +47,8 @@ class TextEditor:
|
||||
def display(self):
|
||||
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")
|
||||
|
Loading…
Reference in New Issue
Block a user