-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathlea_common-user_options.adb
172 lines (163 loc) · 6.37 KB
/
lea_common-user_options.adb
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
with Ada.Strings.Wide_Fixed;
package body LEA_Common.User_options is
procedure Toggle_show_special (o : in out Option_Pack_Type) is
begin
if o.show_special = Show_special_symbol_mode'Last then
o.show_special := Show_special_symbol_mode'First;
else
o.show_special := Show_special_symbol_mode'Succ (o.show_special);
end if;
end Toggle_show_special;
package body Persistence is
sep : constant UTF_16_String := ">";
procedure Load (opt : out Option_Pack_Type) is
mru_idx : Positive;
sep_pos_1 : Natural;
use Ada.Strings.Wide_Fixed;
begin
for k in Persistence_Key loop
begin
declare
s : constant Wide_String := Read_Key (k);
begin
case k is
when view_mode =>
opt.view_mode := View_Mode_Type'Wide_Value (s);
when toolset_mode =>
opt.toolset := Toolset_mode_type'Wide_Value (s);
when color_theme =>
opt.color_theme := Color_Themes.Color_Theme_Type'Wide_Value (s);
when backup =>
opt.backup := Backup_mode'Wide_Value (s);
when indent =>
opt.indentation := Integer'Wide_Value (s);
when tab_width =>
opt.tab_width := Integer'Wide_Value (s);
when edge =>
opt.right_margin := Integer'Wide_Value (s);
when show_special =>
opt.show_special := Show_special_symbol_mode'Wide_Value (s);
when show_indent =>
opt.show_indent := Boolean'Wide_Value (s);
when auto_insert =>
opt.auto_insert := Boolean'Wide_Value (s);
when win_left =>
opt.win_left := Integer'Wide_Value (s);
when win_top =>
opt.win_top := Integer'Wide_Value (s);
when win_width =>
opt.win_width := Integer'Wide_Value (s);
when win_height =>
opt.win_height := Integer'Wide_Value (s);
when maximized =>
opt.MDI_main_maximized := Boolean'Wide_Value (s);
when children_maximized =>
opt.MDI_childen_maximized := Boolean'Wide_Value (s);
when tree_portion =>
opt.tree_portion := Float'Wide_Value (s);
when project_tree_portion =>
opt.project_tree_portion := Float'Wide_Value (s);
when message_list_portion =>
opt.message_list_portion := Float'Wide_Value (s);
when subprogram_tree_portion =>
opt.subprogram_tree_portion := Float'Wide_Value (s);
when mru1 .. mru9 =>
mru_idx := Persistence_Key'Pos (k) - Persistence_Key'Pos (mru1) + 1;
sep_pos_1 := Index (s, sep);
if sep_pos_1 > 0 then -- Separator between file name and line number
opt.mru (mru_idx).name := To_Unbounded_Wide_String (s (s'First .. sep_pos_1 - 1));
opt.mru (mru_idx).line := Integer'Wide_Value (s (sep_pos_1 + 1 .. s'Last));
else
opt.mru (mru_idx).name := To_Unbounded_Wide_String (s);
end if;
when ada_files_filter =>
if s /= "" and then
s (s'First) = '*'
-- ^ Filter registry garbage AND check that first chatacter is a '*'...
then
opt.ada_files_filter := To_Unbounded_Wide_String (s);
end if;
when smart_editor =>
opt.smart_editor := Boolean'Wide_Value (s);
end case;
end;
exception
when others =>
null;
-- This key is missing (from registry, config file,...)
-- Data_Error or something else.
-- We just continue...
end;
end loop;
end Load;
procedure Save (opt : in Option_Pack_Type) is
mru_idx : Positive;
begin
for k in Persistence_Key loop
declare
procedure R (v : Wide_String) is
begin
Write_Key (k, v);
end R;
begin
case k is
when view_mode =>
R (opt.view_mode'Wide_Image);
when toolset_mode =>
R (opt.toolset'Wide_Image);
when color_theme =>
R (opt.color_theme'Wide_Image);
when backup =>
R (opt.backup'Wide_Image);
when indent =>
R (opt.indentation'Wide_Image);
when tab_width =>
R (opt.tab_width'Wide_Image);
when edge =>
R (opt.right_margin'Wide_Image);
when show_special =>
R (opt.show_special'Wide_Image);
when show_indent =>
R (opt.show_indent'Wide_Image);
when auto_insert =>
R (opt.auto_insert'Wide_Image);
when win_left =>
R (opt.win_left'Wide_Image);
when win_top =>
R (opt.win_top'Wide_Image);
when win_width =>
R (opt.win_width'Wide_Image);
when win_height =>
R (opt.win_height'Wide_Image);
when maximized =>
R (opt.MDI_main_maximized'Wide_Image);
when children_maximized =>
R (opt.MDI_childen_maximized'Wide_Image);
when tree_portion =>
R (opt.tree_portion'Wide_Image);
when project_tree_portion =>
R (opt.tree_portion'Wide_Image);
when message_list_portion =>
R (opt.message_list_portion'Wide_Image);
when subprogram_tree_portion =>
R (opt.subprogram_tree_portion'Wide_Image);
when mru1 .. mru9 =>
mru_idx := Persistence_Key'Pos (k) - Persistence_Key'Pos (mru1) + 1;
R (To_Wide_String (opt.mru (mru_idx).name) & sep &
opt.mru (mru_idx).line'Wide_Image);
when ada_files_filter =>
R (To_Wide_String (opt.ada_files_filter));
when smart_editor =>
R (opt.smart_editor'Wide_Image);
end case;
end;
end loop;
end Save;
end Persistence;
procedure Show_Persistence_Keys is
begin
for k in Persistence_Key loop
String_Output (k'Image);
end loop;
end Show_Persistence_Keys;
end LEA_Common.User_options;