Skip to content

Commit 9a39708

Browse files
Add lowercase naming for AppVars
Co-Authored-By: RoccoLox Programs <roccoloxprograms2018@gmail.com>
1 parent 5ce8caf commit 9a39708

File tree

10 files changed

+53
-44
lines changed

10 files changed

+53
-44
lines changed

makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
NAME = CEaShell
1111
APP_NAME = CEaShell
1212
APP_VERSION = 5.0.0.0000
13-
CEASHELL_VERSION = 1.0.6
13+
CEASHELL_VERSION = 1.1
1414
APPVAR_VERSION = 0
1515
DESCRIPTION = "(C) 2022-2023 RoccoLox & TIny_Hacker"
1616
COMPRESSED = NO

src/gfx/convimg.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ converts:
2222
- rArrow.png
2323
- dArrow.png
2424
- check.png
25-
- cursorAlpha.png
2625
- cursorNumber.png
26+
- cursorUpper.png
27+
- cursorLower.png
2728
- batteryAlt.png
2829
- chargingAlt.png
2930
- paintAlt.png
@@ -33,8 +34,9 @@ converts:
3334
- rArrowAlt.png
3435
- dArrowAlt.png
3536
- checkAlt.png
36-
- cursorAlphaAlt.png
3737
- cursorNumberAlt.png
38+
- cursorUpperAlt.png
39+
- cursorLowerAlt.png
3840
- invSwitch.png
3941

4042
outputs:

src/gfx/cursorLower.png

5.98 KB
Loading

src/gfx/cursorLowerAlt.png

5.96 KB
Loading

src/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* By RoccoLox Programs and TIny_Hacker
66
* Copyright 2022 - 2023
77
* License: GPL-3.0
8-
* Last Build: January 25, 2023
9-
* Version: 1.0.6
8+
* Last Build: February 24, 2023
9+
* Version: 1.1
1010
*
1111
* --------------------------------------
1212
**/
@@ -574,7 +574,7 @@ int main(void) {
574574
} else if (kb_IsDown(kb_KeyMode) && fileSelected >= 0 + ((directory == PROGRAMS_FOLDER) * (showApps + showAppvars)) + (directory != PROGRAMS_FOLDER)) {
575575
fullRedraw = true;
576576
char name[9] = "\0";
577-
uint8_t copyMenu = ui_CopyNewMenu(colors, name);
577+
uint8_t copyMenu = ui_CopyNewMenu(colors, name, (directory == APPVARS_FOLDER));
578578

579579
if (copyMenu == 2) {
580580
while (kb_AnyKey());

src/menu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@ void menu_Info(uint8_t *colors, void **programPtrs, void **appvarPtrs, bool *inf
10221022
newName[0] += 64 * (newName[0] < 65);
10231023
menu_InfoRedraw(true, false, colors, cursorX, cursorY, isArchived, isLocked, isHidden, fileTypeString, newName, fileSize, fileType, osFileType, directory);
10241024

1025-
if (ui_RenameBox(colors, newName)) {
1025+
if (ui_RenameBox(colors, newName, (directory == APPVARS_FOLDER))) {
10261026
ti_Close(slot);
10271027
ti_RenameVar(fileName, newName, osFileType);
10281028
sortVAT();

src/ui.c

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
void ui_DrawUISprite(const uint8_t color, const uint8_t spriteNo, const int x, const uint8_t y) {
3030
bool colorAlt = !(color > 131 && color % 8 > 3);
31-
const gfx_sprite_t *uiIcons[22] = {battery, charging, paint, info, settings, lArrow, rArrow, dArrow, check, cursorAlpha, cursorNumber, batteryAlt, chargingAlt, paintAlt, infoAlt, settingsAlt, lArrowAlt, rArrowAlt, dArrowAlt, checkAlt, cursorAlphaAlt, cursorNumberAlt};
31+
const gfx_sprite_t *uiIcons[24] = {battery, charging, paint, info, settings, lArrow, rArrow, dArrow, check, cursorNumber, cursorUpper, cursorLower, batteryAlt, chargingAlt, paintAlt, infoAlt, settingsAlt, lArrowAlt, rArrowAlt, dArrowAlt, checkAlt, cursorNumberAlt, cursorUpperAlt, cursorLowerAlt};
3232
gfx_TransparentSprite_NoClip(uiIcons[spriteNo + colorAlt * 11], x, y);
3333
gfx_SetTextFGColor(colorAlt * 255);
3434
}
@@ -262,10 +262,14 @@ bool ui_DeleteConf(uint8_t *colors, const int x, const uint8_t y) {
262262
return retVal;
263263
}
264264

265-
bool ui_RenameBox(uint8_t *colors, char *newName) {
265+
bool ui_RenameBox(uint8_t *colors, char *newName, bool useLower) {
266266
gfx_BlitScreen();
267-
const char *charAlpha = "\0\0\0\0\0\0\0\0\0\0\0WRMH\0\0\0[VQLG\0\0\0ZUPKFC\0\0YTOJEBX\0XSNIDA\0\0\0\0\0\0\0\0";
268-
const char *charNums = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0""369\0\0\0\0\0""258\0\0\0\0""0147\0\0\0X\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
267+
268+
static const char chars[3][56] =
269+
{{'\0', '\0', '\0', '\0', '\0','\0', '\0', '\0', '\0', '\0', '+', '-', '*', '/', '^', '\0', '\0', '\0', '3', '6', '9', ')', '\0', '\0', '\0', '.', '2', '5', '8', '(', '\0', '\0', '\0', '0', '1', '4', '7', ',', '\0', '\0', 'X', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'},
270+
{'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\"', 'W', 'R', 'M', 'H', '\0', '\0', '?', '[', 'V', 'Q', 'L', 'G', '\0', '\0', ':', 'Z', 'U', 'P', 'K', 'F', 'C', '\0', ' ', 'Y', 'T', 'O', 'J', 'E', 'B', 'X', '\0', 'X', 'S', 'N', 'I', 'D', 'A', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'},
271+
{'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\"', 'w', 'r', 'm', 'h', '\0', '\0', '?', '[', 'v', 'q', 'l', 'g', '\0', '\0', ':', 'z', 'u', 'p', 'k', 'f', 'c', '\0', ' ', 'y', 't', 'o', 'j', 'e', 'b', '\0', '\0', 'x', 's', 'n', 'i', 'd' ,'a', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'}};
272+
269273
uint8_t length = strlen(newName);
270274
gfx_SetColor(colors[0]);
271275
gfx_FillRectangle_NoClip(129, 182, 62, 11);
@@ -279,7 +283,7 @@ bool ui_RenameBox(uint8_t *colors, char *newName) {
279283
while (kb_AnyKey());
280284
uint8_t key = os_GetCSC();
281285
bool redraw;
282-
bool alphaPressed = false; // Number mode?
286+
uint8_t inputMode = INPUT_UPPER;
283287
bool cursor = false;
284288
timer_Set(1, 0);
285289

@@ -296,16 +300,9 @@ bool ui_RenameBox(uint8_t *colors, char *newName) {
296300
redraw = true;
297301
}
298302

299-
if (!alphaPressed) {
300-
if (charAlpha[key] && length < 8) {
301-
newName[length++] = charAlpha[key];
302-
redraw = true;
303-
}
304-
} else {
305-
if (charNums[key] && length < 8 && length) {
306-
newName[length++] = charNums[key];
307-
redraw = true;
308-
}
303+
if (chars[inputMode][key]) {
304+
newName[length++] = chars[inputMode][key];
305+
redraw = true;
309306
}
310307

311308
if (redraw) {
@@ -323,11 +320,15 @@ bool ui_RenameBox(uint8_t *colors, char *newName) {
323320
}
324321

325322
if (key == sk_Alpha) {
326-
alphaPressed = !alphaPressed;
323+
if (inputMode < 2 - !(useLower)) {
324+
inputMode++;
325+
} else {
326+
inputMode = 0;
327+
}
327328
}
328329
} else {
329330
if (cursor) {
330-
ui_DrawUISprite(colors[1], UI_CURSOR_A + alphaPressed, gfx_GetTextX() + 1, gfx_GetTextY());
331+
ui_DrawUISprite(colors[1], UI_CURSOR_1 + inputMode, gfx_GetTextX() + 1, gfx_GetTextY());
331332
} else {
332333
gfx_SetColor(colors[2]);
333334
gfx_FillRectangle_NoClip(gfx_GetTextX() + 1, gfx_GetTextY(), 7, 14);
@@ -692,7 +693,7 @@ void ui_NewUser(void) {
692693
}
693694
}
694695

695-
uint8_t ui_CopyNewMenu(uint8_t *colors, char *name) {
696+
uint8_t ui_CopyNewMenu(uint8_t *colors, char *name, bool useLower) {
696697
bool returnVal = false;
697698
while (kb_AnyKey());
698699
shapes_RoundRectangleFill(colors[0], 9, 208, 20, 56, 204);
@@ -732,13 +733,17 @@ uint8_t ui_CopyNewMenu(uint8_t *colors, char *name) {
732733
gfx_SetTextScale(2, 2);
733734
gfx_SetTextXY(111, 207);
734735
gfx_BlitBuffer();
735-
const char *charAlpha = "\0\0\0\0\0\0\0\0\0\0\0WRMH\0\0\0[VQLG\0\0\0ZUPKFC\0\0YTOJEBX\0XSNIDA\0\0\0\0\0\0\0\0";
736-
const char *charNums = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0""369\0\0\0\0\0""258\0\0\0\0""0147\0\0\0X\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
736+
737+
static const char chars[3][56] =
738+
{{'\0', '\0', '\0', '\0', '\0','\0', '\0', '\0', '\0', '\0', '+', '-', '*', '/', '^', '\0', '\0', '\0', '3', '6', '9', ')', '\0', '\0', '\0', '.', '2', '5', '8', '(', '\0', '\0', '\0', '0', '1', '4', '7', ',', '\0', '\0', 'X', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'},
739+
{'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\"', 'W', 'R', 'M', 'H', '\0', '\0', '?', '[', 'V', 'Q', 'L', 'G', '\0', '\0', ':', 'Z', 'U', 'P', 'K', 'F', 'C', '\0', ' ', 'Y', 'T', 'O', 'J', 'E', 'B', 'X', '\0', 'X', 'S', 'N', 'I', 'D', 'A', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'},
740+
{'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\"', 'w', 'r', 'm', 'h', '\0', '\0', '?', '[', 'v', 'q', 'l', 'g', '\0', '\0', ':', 'z', 'u', 'p', 'k', 'f', 'c', '\0', ' ', 'y', 't', 'o', 'j', 'e', 'b', '\0', '\0', 'x', 's', 'n', 'i', 'd' ,'a', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'}};
741+
737742
asm("ei");
738743
uint8_t length = 0;
739744
uint8_t key = os_GetCSC();
740745
bool redraw;
741-
bool alphaPressed; // Number mode?
746+
uint8_t inputMode = INPUT_UPPER;
742747
bool cursor = false;
743748
timer_Set(1, 0);
744749

@@ -755,16 +760,9 @@ uint8_t ui_CopyNewMenu(uint8_t *colors, char *name) {
755760
redraw = true;
756761
}
757762

758-
if (!alphaPressed) {
759-
if (charAlpha[key] && length < 8) {
760-
name[length++] = charAlpha[key];
761-
redraw = true;
762-
}
763-
} else {
764-
if (charNums[key] && length < 8 && length) {
765-
name[length++] = charNums[key];
766-
redraw = true;
767-
}
763+
if (chars[inputMode][key]) {
764+
name[length++] = chars[inputMode][key];
765+
redraw = true;
768766
}
769767

770768
if (redraw) {
@@ -782,11 +780,15 @@ uint8_t ui_CopyNewMenu(uint8_t *colors, char *name) {
782780
}
783781

784782
if (key == sk_Alpha) {
785-
alphaPressed = !alphaPressed;
783+
if (inputMode < 2 - !(useLower)) {
784+
inputMode++;
785+
} else {
786+
inputMode = 0;
787+
}
786788
}
787789
} else {
788790
if (cursor) {
789-
ui_DrawUISprite(colors[1], UI_CURSOR_A + alphaPressed, gfx_GetTextX() + 1, gfx_GetTextY());
791+
ui_DrawUISprite(colors[1], UI_CURSOR_1 + inputMode, gfx_GetTextX() + 1, gfx_GetTextY());
790792
} else {
791793
gfx_SetColor(colors[0]);
792794
gfx_FillRectangle_NoClip(gfx_GetTextX() + 1, gfx_GetTextY(), 7, 14);

src/ui.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
extern "C" {
2020
#endif
2121

22+
#define INPUT_NUMBER 0
23+
#define INPUT_UPPER 1
24+
#define INPUT_LOWER 2
25+
2226
#define UI_BATTERY 0
2327
#define UI_CHARGING 1
2428
#define UI_PAINT 2
@@ -28,8 +32,9 @@ extern "C" {
2832
#define UI_RARROW 6
2933
#define UI_DARROW 7
3034
#define UI_CHECK 8
31-
#define UI_CURSOR_A 9
32-
#define UI_CURSOR_1 10
35+
#define UI_CURSOR_1 9
36+
#define UI_CURSOR_UP 10
37+
#define UI_CURSOR_LOW 11
3338

3439
void ui_DrawUISprite(const uint8_t color, const uint8_t spriteNo, const int x, const uint8_t y); // Takes care of drawing the sprite in white or black, depending on the theme
3540

@@ -49,7 +54,7 @@ void ui_BottomBar(const uint8_t color);
4954

5055
bool ui_DeleteConf(uint8_t *colors, const int x, const uint8_t y);
5156

52-
bool ui_RenameBox(uint8_t *colors, char *newName);
57+
bool ui_RenameBox(uint8_t *colors, char *newName, bool useLower);
5358

5459
void ui_DrawAllFiles(uint8_t *colors, void **programPtrs, void **appvarPtrs, const uint8_t fileSelected, const uint8_t fileCount, const unsigned int fileStartLoc, const uint8_t directory, const bool displayCEaShell, const bool showHiddenProg, const bool showApps, const bool showAppvars);
5560

@@ -63,7 +68,7 @@ void ui_AboutScreen(uint8_t *colors);
6368

6469
void ui_NewUser(void);
6570

66-
uint8_t ui_CopyNewMenu(uint8_t *colors, char *name);
71+
uint8_t ui_CopyNewMenu(uint8_t *colors, char *name, bool useLower);
6772

6873
#ifdef __cplusplus
6974
}

0 commit comments

Comments
 (0)