-
Notifications
You must be signed in to change notification settings - Fork 109
/
TESTING-Syntax.py
executable file
·52 lines (43 loc) · 1.73 KB
/
TESTING-Syntax.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python
# encoding: utf-8
import curses
import npyscreen
#npyscreen.disableColor()
class SyntaxTest(npyscreen.Textfield):
def update_highlighting(self, start, end):
# highlighting color
hl_color = self.parent.theme_manager.findPair(self, 'IMPORTANT')
hl_colorb = self.parent.theme_manager.findPair(self, 'WARNING')
hl_colorc = self.parent.theme_manager.findPair(self, 'CRITICAL')
self._highlightingdata = [curses.A_BOLD,
curses.A_BOLD,
hl_color,
hl_color,
hl_color,
hl_color,
hl_colorb,
hl_colorb,
hl_colorc,
hl_colorc,
hl_colorc,
hl_colorc,
]
#class SyntaxTestMultiline(npyscreen.MultiLineEdit):
# def update_highlighting(self, start, end):
# self._highlightingdata = [curses.A_BOLD, curses.A_BOLD, curses.A_BOLD]
class TestApp(npyscreen.NPSApp):
def main(self):
# These lines create the form and populate it with widgets.
# A fairly complex screen in only 8 or so lines of code - a line for each control.
F = npyscreen.Form(name = "Welcome to Npyscreen",)
t = F.add(SyntaxTest, name = "Text:",)
t.syntax_highlighting = True
ml= F.add(npyscreen.MultiLineEdit,
value = """try typing here!\nMutiline text, press ^R to reformat.\n""",
max_height=5, rely=9)
ml.syntax_highlighting = True
# This lets the user play with the Form.
F.edit()
if __name__ == "__main__":
App = TestApp()
App.run()