Skip to content

Commit 8e63da6

Browse files
committed
Merge pull request #28 from chrisws/0_11_19
0 11 19
2 parents bd83dd3 + bf0fa01 commit 8e63da6

File tree

6 files changed

+349
-66
lines changed

6 files changed

+349
-66
lines changed

documentation/build_kwp.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <ctype.h>
77
#include <stdlib.h>
88
#include <unistd.h>
9+
#include <stdint.h>
910
#include "../src/ui/strlib.h"
1011

1112
#define code_t int
@@ -45,6 +46,7 @@ struct spopr_keyword_s {
4546
struct HelpItem {
4647
char package[20];
4748
char keyword[20];
49+
char type[20];
4850
char id[20];
4951
char signature[128];
5052
char help[1024];
@@ -177,6 +179,8 @@ bool readHelpReference(strlib::List<HelpItem *> *helpItems) {
177179
break;
178180
case 1:
179181
// type
182+
strncpy(item->type, lineBuffer + start, fieldLen);
183+
item->type[fieldLen] = '\0';
180184
break;
181185
case 2:
182186
// keyword
@@ -215,6 +219,16 @@ bool readHelpReference(strlib::List<HelpItem *> *helpItems) {
215219
return true;
216220
}
217221

222+
uint32_t getHash(const char *key) {
223+
uint32_t hash, i;
224+
for (hash = i = 0; key[i] != '\0'; i++) {
225+
hash += tolower(key[i]);
226+
hash += (hash << 3);
227+
hash ^= (hash >> 1);
228+
}
229+
return hash;
230+
}
231+
218232
int main(int argc, char *argv[]) {
219233
strlib::List<HelpItem *> helpItems;
220234
if (!readHelpReference(&helpItems)) {
@@ -228,12 +242,44 @@ int main(int argc, char *argv[]) {
228242
fprintf(stdout, " const char *signature;\n");
229243
fprintf(stdout, " const char *help;\n");
230244
fprintf(stdout, "} keyword_help[] = {\n");
245+
246+
int max_keyword_len = 0;
231247
List_each(HelpItem *, it, helpItems) {
232248
HelpItem *item = (*it);
233249
fprintf(stdout, "{\"%s\",\"%s\",\"%s\",\"%s\"},\n", item->package,
234250
item->keyword, item->signature, item->help);
251+
int len = strlen(item->keyword);
252+
if (len > max_keyword_len) {
253+
max_keyword_len = len;
254+
}
235255
}
236256
fprintf(stdout, "};\n");
237257
fprintf(stdout, "const int keyword_help_len = %d;\n", helpItems.size());
258+
fprintf(stdout, "const int keyword_max_len = %d;\n", max_keyword_len);
259+
260+
int count = 0;
261+
fprintf(stdout, "const uint32_t keyword_hash_statement[] = {\n");
262+
List_each(HelpItem *, it, helpItems) {
263+
HelpItem *item = (*it);
264+
if (strcasecmp(item->package, "Language") == 0) {
265+
count++;
266+
fprintf(stdout, " %uu,\n", getHash(item->keyword));
267+
}
268+
}
269+
fprintf(stdout, "};\n");
270+
fprintf(stdout, "const int keyword_hash_statement_len = %d;\n", count);
271+
272+
count = 0;
273+
fprintf(stdout, "const uint32_t keyword_hash_command[] = {\n");
274+
List_each(HelpItem *, it, helpItems) {
275+
HelpItem *item = (*it);
276+
if (strcasecmp(item->package, "Language") != 0) {
277+
count++;
278+
fprintf(stdout, " %uu,\n", getHash(item->keyword));
279+
}
280+
}
281+
fprintf(stdout, "};\n");
282+
fprintf(stdout, "const int keyword_hash_command_len = %d;\n", count);
283+
238284
return 0;
239285
}

src/platform/sdl/keymap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const int shiftmap[][2] = {
6363
{'8', '*'},
6464
{'9', '('},
6565
{'0', ')'},
66-
{'-', '-'},
66+
{'-', '_'},
6767
{'=', '+'},
6868
{'[', '{'},
6969
{']', '}'},

src/platform/sdl/settings.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include "ui/utils.h"
1818
#include "common/smbas.h"
1919

20+
extern int g_themeId;
21+
2022
static const char *ENV_VARS[] = {
2123
"APPDATA", "HOME", "TMP", "TEMP", "TMPDIR"
2224
};
@@ -88,6 +90,7 @@ void restoreSettings(const char *configName, SDL_Rect &rect, int &fontScale) {
8890
fontScale = nextInteger(fp, DEFAULT_SCALE);
8991
opt_mute_audio = nextInteger(fp, 0);
9092
opt_ide = nextInteger(fp, 0);
93+
g_themeId = nextInteger(fp, 0);
9194
fclose(fp);
9295
} else {
9396
rect.x = SDL_WINDOWPOS_UNDEFINED;
@@ -97,6 +100,7 @@ void restoreSettings(const char *configName, SDL_Rect &rect, int &fontScale) {
97100
fontScale = DEFAULT_SCALE;
98101
opt_mute_audio = 0;
99102
opt_ide = IDE_NONE;
103+
g_themeId = 0;
100104
}
101105
}
102106

@@ -109,7 +113,8 @@ void saveSettings(const char *configName, SDL_Window *window, int fontScale) {
109113
int x, y, w, h;
110114
SDL_GetWindowPosition(window, &x, &y);
111115
SDL_GetWindowSize(window, &w, &h);
112-
fprintf(fp, "%d,%d,%d,%d,%d,%d,%d\n", x, y, w, h, fontScale, opt_mute_audio, opt_ide);
116+
fprintf(fp, "%d,%d,%d,%d,%d,%d,%d,%d\n", x, y, w, h,
117+
fontScale, opt_mute_audio, opt_ide, g_themeId);
113118
fclose(fp);
114119
}
115120
}

src/ui/system.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,15 @@ void System::editSource(strlib::String &loadPath) {
9595
fileName = loadPath;
9696
}
9797

98+
const char *help = " Ctrl+h (C-h)=Help";
9899
strlib::String dirtyFile;
99100
dirtyFile.append(" * ");
100101
dirtyFile.append(fileName);
101-
dirtyFile.append(" C-h=Help");
102+
dirtyFile.append(help);
102103
strlib::String cleanFile;
103104
cleanFile.append(" - ");
104105
cleanFile.append(fileName);
105-
cleanFile.append(" C-h=Help");
106+
cleanFile.append(help);
106107

107108
int w = _output->getWidth();
108109
int h = _output->getHeight();

0 commit comments

Comments
 (0)