46
46
helpCode, highlightValid, highlightInvalid, highlightVariable,
47
47
highlightText, suggestInvalid, suggestCommand, suggestYes, suggestNext,
48
48
suggestAbort, promptColor, promptError, completionList
49
+ ColorDescription = string
49
50
Color * {.tableName : " theme" .} = ref object of Model
50
51
# # Data structure for the shell's color
51
52
# #
55
56
# # * bold - if true, set the color with a bold font
56
57
# # * underline - if true, add underline to the color
57
58
# # * italic - if true, set the color with an italic font
58
- name* {.unique .}: ThemeColor
59
- cValue* : ColorName
60
- description* : string
61
- bold* : bool
62
- underline* : bool
63
- italic* : bool
59
+ name {.unique .}: ThemeColor
60
+ cValue: ColorName
61
+ description: ColorDescription
62
+ bold: bool
63
+ underline: bool
64
+ italic: bool
64
65
ColorCode * = string
65
66
# # Used to get the terminal code for a color
66
67
@@ -69,6 +70,36 @@ using db: DbConn # Connection to the shell's database
69
70
const themeCommands* : seq [string ] = @ [" list" , " edit" , " reset" ]
70
71
# # The list of available subcommands for command theme
71
72
73
+ template colorGetterSetter (name: untyped ; typ: typedesc ) =
74
+ # # Set the getter for a field of Color type
75
+ # #
76
+ # # * name - the name of the field for which the getter will be set
77
+ # # * typ - the type of the value of the field
78
+ proc `name` * (col: Color ): `typ` {.sideEffect , raises : [], tags : [],
79
+ contractual .} =
80
+ # # The getter of a field of Color type
81
+ # #
82
+ # # * col - the shell's color
83
+ # #
84
+ # # Returns the value of the selected field
85
+ col.`name`
86
+ proc `name=` * (col: var Color ; value: `typ`) {.sideEffect , raises : [],
87
+ tags : [], contractual .} =
88
+ # # The setter of a field of Color type
89
+ # #
90
+ # # * col - the shell's color
91
+ # # * value - the new value for the selected field
92
+ # #
93
+ # # Returns modified field of the color
94
+ col.`name` = value
95
+
96
+ colorGetterSetter (name = name, typ = ThemeColor )
97
+ colorGetterSetter (name = cValue, typ = ColorName )
98
+ colorGetterSetter (name = description, typ = ColorDescription )
99
+ colorGetterSetter (name = bold, typ = bool )
100
+ colorGetterSetter (name = underline, typ = bool )
101
+ colorGetterSetter (name = italic, typ = bool )
102
+
72
103
proc dbType (T: typedesc [ColorName ]): string {.raises : [], tags : [],
73
104
contractual .} =
74
105
# # Set the type of field in the database
0 commit comments