Skip to content

Commit 8e40197

Browse files
committed
Layout and front-end improvements for version 0.3.0
Fixes #11
1 parent d43972e commit 8e40197

File tree

5 files changed

+49
-32
lines changed

5 files changed

+49
-32
lines changed

docs/ConfigurationGuide.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ It makes use of all of the features currently implemented by the application.
1212
- [The `keys` Section](#the-keys-section)
1313
- [The `label` Item](#the-label-item)
1414
- [The `colspan` and `rowspan` Items](#the-colspan-and-rowspan-items)
15+
- [The `bg` Item](#the-bg-item)
1516
- [The `send` Item](#the-send-item)
1617
- [Special Keys and Modifiers](#special-keys-and-modifiers)
1718
- [`Shift+`](#shift)
@@ -52,6 +53,7 @@ You add one `[[tab]]` section for each tab (page) of buttons you want to display
5253
There are a couple of compulsory config items for the tab itself, then a table of key definitions (see below).
5354

5455
Every tab must contain a `label`, a `cols`, and a `keys` item.
56+
There is an optional `fontsize` option.
5557

5658
The `label` item is a simple string displayed at the top of the tab of keys.
5759

@@ -62,11 +64,15 @@ Eg.
6264
```
6365
[[tab]]
6466
label = "French"
65-
cols = 3
67+
cols = 3
68+
fontsize = "20pt"
6669
...
6770
```
71+
The optional `fontsize` item is a string consisting of a number and unit-specifier.
6872

69-
After these two items comes the meat of the config file: the ``keys`` defintions.
73+
Eg. `fontsize = "12pt"` or `fontsize = "22mm"`.
74+
75+
Next comes the meat of the config file: the ``keys`` defintions.
7076

7177
## The `keys` Section
7278
This is where the keys are defined, in order, from left to right.

examples/keypad.toml

+9-8
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,14 @@ keys = [
123123
[[tab]]
124124
label = "LibreOffice" # Testing all the modifiers
125125
cols = 2
126+
fontsize = "20pt"
126127
keys = [
127-
{ label = "Help", send = "F1" },
128-
{ label = "Options", send = "Alt+F12" },
129-
{ label = "Spell", send = "Shift+F7" },
130-
{ label = "Thes.", send = "Ctrl+F7" },
131-
{ label = "Currency", send = "Ctrl+Shift+4" },
132-
{ label = "Percent", send = "Ctrl+Shift+5" },
133-
{ label = "Comment", send = "Ctrl+Alt+C" },
134-
{ label = "PasteUnf", send = "Ctrl+Alt+Shift+V" },
128+
{ label = "Help", send = "F1" },
129+
{ label = "Options", send = "Alt+F12" },
130+
{ label = "Spelling", send = "Shift+F7" },
131+
{ label = "Thesaurus", send = "Ctrl+F7" },
132+
{ label = "As Currency", send = "Ctrl+Shift+4" },
133+
{ label = "As Percentage", send = "Ctrl+Shift+5" },
134+
{ label = "Comment", send = "Ctrl+Alt+C" },
135+
{ label = "Paste
Unformatted", send = "Ctrl+Alt+Shift+V" },
135136
]

src/config.adb

+5
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,11 @@ package body Config is
207207
Tab := Item (Tabs_Array, T);
208208
New_Tab.Label := As_Unbounded_String (Get (Tab, "label"));
209209
New_Tab.Columns := Natural (As_Integer (Get (Tab, "cols")));
210+
if Has (Tab, "fontsize") then
211+
New_Tab.Fontsize := As_Unbounded_String (Get (Tab, "fontsize"));
212+
else
213+
New_Tab.Fontsize := Null_Unbounded_String;
214+
end if;
210215
-- Put_Line ("Tab defined:" & Dump_As_String (Tab));
211216
if Verbose then
212217
Put_Line ("Tab: " & To_String (New_Tab.Label) &

src/config.ads

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ package Config is
4848
type Tab_T is record
4949
Label : Unbounded_String;
5050
Columns : Natural := 0;
51+
Fontsize : Unbounded_String := Null_Unbounded_String;
5152
Keys : Key_Vectors.Vector;
5253
end record;
5354

src/frontend.adb

+26-22
Original file line numberDiff line numberDiff line change
@@ -60,63 +60,67 @@ package body Frontend is
6060
"xhr.send(); return false; }" &
6161
"</script>" &
6262
"</form></body></html>";
63-
Main_Page_HTML : Unbounded_String := Null_Unbounded_String;
63+
Main_HTML : Unbounded_String := Null_Unbounded_String;
6464
begin
65-
Append (Main_Page_HTML, Header_HTML);
65+
Append (Main_HTML, Header_HTML);
6666

6767
-- first the tab headers or selector
6868
if Conf.Keypadder_Conf.Tabswitch = Tabs then
69-
Append (Main_Page_HTML, "<div class=""kp-bar"">");
69+
Append (Main_HTML, "<div class=""kp-bar"">");
7070
for Tab of Conf.Tabs loop
71-
Append (Main_Page_HTML, "<button class=""kp-bar-item"" onclick=""openTab('" &
71+
Append (Main_HTML, "<button class=""kp-bar-item"" onclick=""openTab('" &
7272
Tab.Label & "')"">" &
7373
Tab.Label & "</button>");
7474
end loop;
7575
else -- selector
76-
Append (Main_Page_HTML, "<div><select class='kp-selector' id='kpselect' onChange='selectChange()'>");
76+
Append (Main_HTML, "<div><select class='kp-selector' id='kpselect' onChange='selectChange()'>");
7777
for Tab of Conf.Tabs loop
78-
Append (Main_Page_HTML, "<option value='" & Tab.Label & "'>");
79-
Append (Main_Page_HTML, Tab.Label & "</option>");
78+
Append (Main_HTML, "<option value='" & Tab.Label & "'>");
79+
Append (Main_HTML, Tab.Label & "</option>");
8080
end loop;
81-
Append (Main_Page_HTML, "</select>");
81+
Append (Main_HTML, "</select>");
8282
end if;
83-
Append (Main_Page_HTML, "</div>" & ASCII.LF);
83+
Append (Main_HTML, "</div>" & ASCII.LF);
8484

85-
Append (Main_Page_HTML, "<form id=""kpForm"" onsubmit=""return ajaxget()"">" & ASCII.LF);
85+
Append (Main_HTML, "<form id=""kpForm"" onsubmit=""return ajaxget()"">" & ASCII.LF);
8686
-- now each tab
8787
for T in Conf.Tabs.First_Index .. Conf.Tabs.Last_Index loop
88-
Append (Main_Page_HTML, "<div id=""" & Conf.Tabs (T).Label & """ class=""kp-pad""");
88+
Append (Main_HTML, "<div id=""" & Conf.Tabs (T).Label & """ class=""kp-pad""");
8989
if T /= Active_Tab then -- hide inactive Tabs
90-
Append (Main_Page_HTML, " style=""display:none""");
90+
Append (Main_HTML, " style=""display:none""");
9191
end if;
92-
Append (Main_Page_HTML, ">" & ASCII.LF);
92+
Append (Main_HTML, ">" & ASCII.LF);
9393

9494
-- the main content of each tab - i.e. the keys
95-
Append (Main_Page_HTML, "<div style=""margin: 0 auto; display: grid; gap: 1rem; align-content: stretch; " &
95+
Append (Main_HTML, "<div style=""margin: 0 auto; display: grid; gap: 1rem; align-content: stretch; " &
9696
"position: fixed; top: 17mm; left: 0; right: 0; bottom: 2px; " &
9797
"overflow: scroll; " &
9898
"grid-template-columns: repeat(" & Conf.Tabs (T).Columns'Image & ", 1fr);"">");
9999
for K in Conf.Tabs (T).Keys.First_Index .. Conf.Tabs (T).Keys.Last_Index loop
100-
Append (Main_Page_HTML, "<input type=""button"" onClick=""return ajaxget(" & T'Image & "," & K'Image & ")"" class=""kp-btn""");
100+
Append (Main_HTML, "<input type=""button"" onClick=""return ajaxget(" & T'Image & "," &
101+
K'Image & ")"" class=""kp-btn"" style=""");
101102
if Conf.Tabs (T).Keys (K).Colspan > 1 then
102-
Append (Main_Page_HTML, " style=""grid-column: span" & Conf.Tabs (T).Keys (K).Colspan'Image & ";"" ");
103+
Append (Main_HTML, " grid-column: span" & Conf.Tabs (T).Keys (K).Colspan'Image & "; ");
103104
end if;
104105
if Conf.Tabs (T).Keys (K).Rowspan > 1 then
105-
Append (Main_Page_HTML, " style=""grid-row: span" & Conf.Tabs (T).Keys (K).Rowspan'Image & ";"" ");
106+
Append (Main_HTML, " rid-row: span" & Conf.Tabs (T).Keys (K).Rowspan'Image & "; ");
106107
end if;
107108
if Conf.Tabs (T).Keys (K).Bg_Colour /= Null_Unbounded_String then
108-
Append (Main_Page_HTML, " style=""background-color: " & Conf.Tabs (T).Keys (K).Bg_Colour & ";"" ");
109+
Append (Main_HTML, " background-color: " & Conf.Tabs (T).Keys (K).Bg_Colour & "; ");
110+
end if;
111+
if Conf.Tabs (T).Fontsize /= Null_Unbounded_String then
112+
Append (Main_HTML, " font-size: " & Conf.Tabs (T).Fontsize & "; ");
109113
end if;
110114
-- the key label
111-
Append (Main_Page_HTML, " value=""" & Conf.Tabs (T).Keys (K).Label & """>" & ASCII.LF);
115+
Append (Main_HTML, """ value=""" & Conf.Tabs (T).Keys (K).Label & """>" & ASCII.LF);
112116
end loop;
113-
Append (Main_Page_HTML, "</div></div>");
117+
Append (Main_HTML, "</div></div>");
114118
end loop;
115119

116120
-- javascript to change displayed tab etc.
117-
Append (Main_Page_HTML, Trailer_HTML);
121+
Append (Main_HTML, Trailer_HTML);
118122

119-
return To_String (Main_Page_HTML);
123+
return To_String (Main_HTML);
120124
end Build_Main_Page;
121125

122126
procedure Decode_And_Send_Key (T, I : String; Tab : out Positive) is

0 commit comments

Comments
 (0)