Skip to content

Commit e2fe88d

Browse files
committed
working on color
1 parent f52cebd commit e2fe88d

File tree

4 files changed

+39
-7
lines changed

4 files changed

+39
-7
lines changed

clid/base.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,16 @@ class ClidTitleText(npy.TitleText):
4040

4141

4242
class ClidCommandLine(npy.fmFormMuttActive.TextCommandBoxTraditional, ClidTextfield):
43-
pass # for making home and end keys work
43+
def print_message(self, msg, color):
44+
"""Print a message into the command line.
45+
46+
Args:
47+
msg(str): message to be displayed.
48+
color(str):
49+
Color with which the message should be displayed. See npyscreen.npysThemes
50+
"""
51+
self.color = color
52+
self.show_bold = True
53+
self.value = msg
54+
#self.color = 'DEFAULT'
55+
#self.show_bold = False

clid/database.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import npyscreen
1010

1111
from . import _const
12+
from . import validators
1213

1314
CONFIG = os.path.expanduser('~/.clid.ini')
1415

@@ -127,9 +128,15 @@ def make_strings(self):
127128
def change_setting(self, key, new):
128129
"""Change a setting in the clid.ini"""
129130
if key in self.settings:
130-
self.settings[key] = new
131-
self.settings.write()
132-
self.when_changed[key]()
131+
try:
132+
validators.VALIDATORS[key](new)
133+
self.settings[key] = new
134+
self.settings.write()
135+
self.when_changed[key]()
136+
except validators.ValidationError as error:
137+
self.parent.wCommand.print_message('Error', 'WARNING')
138+
else:
139+
self.parent.wCommand.print_message(key + ' is not a valid option which can be set', 'WARNING')
133140

134141
def music_dir(self):
135142
"""To be executed when `music_dir` option is changed"""

clid/pref.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ class PrefActionController(base.ClidActionController):
1212
def change_setting(self, command_line, widget_proxy, live):
1313
setting = command_line[5:].split(sep='=')
1414
self.parent.value.change_setting(setting[0], setting[1]) # writes to the ini file
15-
self.parent.value.when_changed[setting[0]]()
1615

1716
self.parent.load_pref()
1817
self.parent.wMain.display()
@@ -28,9 +27,8 @@ def switch_to_main(self, char):
2827
self.parent.parentApp.switchForm("MAIN")
2928

3029
def h_select(self, char):
31-
with open('sdf', 'a') as f:
32-
f.write('multiline: ' + repr(self.parent.value) + '\n')
3330
current_setting = self.values[self.cursor_line].split(maxsplit=1)
31+
self.parent.wCommand.color = 'STANDOUT'
3432
self.parent.wCommand.value = ':set ' + current_setting[0] + '=' + current_setting[1]
3533

3634

sdf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,18 @@ multiline: <clid.database.SettingsDataBase object at 0xb6b5312c>
2727
multiline: <clid.database.SettingsDataBase object at 0xb6b5312c>
2828
multiline: <clid.database.SettingsDataBase object at 0xb6b11e4c>
2929
multiline: <clid.database.SettingsDataBase object at 0xb6b11e4c>
30+
multiline: <clid.database.SettingsDataBase object at 0xb6b34e2c>
31+
multiline: <clid.database.SettingsDataBase object at 0xb6b34e2c>
32+
multiline: <clid.database.SettingsDataBase object at 0xb6b58f4c>
33+
multiline: <clid.database.SettingsDataBase object at 0xb6b58f4c>
34+
multiline: <clid.database.SettingsDataBase object at 0xb6bdf22c>
35+
multiline: <clid.database.SettingsDataBase object at 0xb6bdf22c>
36+
multiline: <clid.database.SettingsDataBase object at 0xb6ba9f8c>
37+
multiline: <clid.database.SettingsDataBase object at 0xb6b0538c>
38+
multiline: <clid.database.SettingsDataBase object at 0xb6baef4c>
39+
multiline: <clid.database.SettingsDataBase object at 0xb6be9f8c>
40+
multiline: <clid.database.SettingsDataBase object at 0xb6bc4fac>
41+
multiline: <clid.database.SettingsDataBase object at 0xb6b1cfac>
42+
multiline: <clid.database.SettingsDataBase object at 0xb6b21fcc>
43+
multiline: <clid.database.SettingsDataBase object at 0xb6b21fcc>
44+
multiline: <clid.database.SettingsDataBase object at 0xb6b21fcc>

0 commit comments

Comments
 (0)