added syntax hilighting nano
This commit is contained in:
parent
d9b34a3f2a
commit
e95470f384
@ -1,6 +1,9 @@
|
|||||||
#["nano", "packages.nano", ["nano"]]
|
#["nano", "packages.nano", ["nano"]]
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
from pygments import highlight
|
||||||
|
from pygments.lexers import PythonLexer
|
||||||
|
from pygments.formatters import TerminalFormatter
|
||||||
|
|
||||||
class TextEditor:
|
class TextEditor:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -42,9 +45,10 @@ class TextEditor:
|
|||||||
print("Invalid command.")
|
print("Invalid command.")
|
||||||
|
|
||||||
def display(self):
|
def display(self):
|
||||||
print("Editing: "+self.file)
|
print("Editing: " + self.file)
|
||||||
for i, line in enumerate(self.lines):
|
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):
|
def newline(self):
|
||||||
self.lines.append("\n")
|
self.lines.append("\n")
|
||||||
|
Loading…
Reference in New Issue
Block a user