From 75b16b8618dd38b65f01d9cf9507547928dcd436 Mon Sep 17 00:00:00 2001 From: Effer Date: Sat, 7 Oct 2017 18:02:53 +0200 Subject: [PATCH 01/26] Run button on code editor --- src/code.c | 6 ++++++ src/studio.c | 13 +++++++++++-- src/studio.h | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/code.c b/src/code.c index e0fd924..d42be5f 100644 --- a/src/code.c +++ b/src/code.c @@ -835,6 +835,11 @@ static void redo(Code* code) update(code); } +static void run() +{ + setStudioMode(TIC_RUN_MODE); +} + static void doTab(Code* code, bool shift) { char* pos = code->cursor.position; @@ -1785,6 +1790,7 @@ static void onStudioEvent(Code* code, StudioEvent event) case TIC_TOOLBAR_PASTE: copyFromClipboard(code); break; case TIC_TOOLBAR_UNDO: undo(code); break; case TIC_TOOLBAR_REDO: redo(code); break; + case TIC_TOOLBAR_RUN: run(); break; } } diff --git a/src/studio.c b/src/studio.c index a4e0085..673f187 100644 --- a/src/studio.c +++ b/src/studio.c @@ -456,11 +456,20 @@ void drawExtrabar(tic_mem* tic) 0b00110000, 0b00000000, 0b00000000, + + 0b00000000, + 0b01000000, + 0b01100000, + 0b01110000, + 0b01100000, + 0b01000000, + 0b00000000, + 0b00000000, }; static const s32 Colors[] = {8, 9, 6, 5, 5}; - static const StudioEvent Events[] = {TIC_TOOLBAR_CUT, TIC_TOOLBAR_COPY, TIC_TOOLBAR_PASTE, TIC_TOOLBAR_UNDO, TIC_TOOLBAR_REDO}; - static const char* Tips[] = {"CUT [ctrl+x]", "COPY [ctrl+c]", "PASTE [ctrl+v]", "UNDO [ctrl+z]", "REDO [ctrl+y]"}; + static const StudioEvent Events[] = {TIC_TOOLBAR_CUT, TIC_TOOLBAR_COPY, TIC_TOOLBAR_PASTE, TIC_TOOLBAR_UNDO, TIC_TOOLBAR_REDO, TIC_TOOLBAR_RUN}; + static const char* Tips[] = {"CUT [ctrl+x]", "COPY [ctrl+c]", "PASTE [ctrl+v]", "UNDO [ctrl+z]", "REDO [ctrl+y]","RUN [ctrl+r]"}; for(s32 i = 0; i < sizeof Icons / BITS_IN_BYTE; i++) { diff --git a/src/studio.h b/src/studio.h index 7c2691d..2b82b68 100644 --- a/src/studio.h +++ b/src/studio.h @@ -172,6 +172,7 @@ typedef enum TIC_TOOLBAR_PASTE, TIC_TOOLBAR_UNDO, TIC_TOOLBAR_REDO, + TIC_TOOLBAR_RUN, } StudioEvent; void setStudioEvent(StudioEvent event); From 1becfa275c13d7a8856a1c53dc81854d529b8ea1 Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Sun, 8 Oct 2017 11:42:29 +0300 Subject: [PATCH 02/26] textri() causes error when using javascript #328 --- src/jsapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jsapi.c b/src/jsapi.c index b090deb..65c9567 100644 --- a/src/jsapi.c +++ b/src/jsapi.c @@ -747,7 +747,7 @@ static const struct{duk_c_function func; s32 params;} ApiFunc[] = {duk_circ, 4}, {duk_circb, 4}, {duk_tri, 7}, - {duk_textri,12}, + {duk_textri,14}, {duk_clip, 4}, {duk_music, 4}, {duk_sync, 0}, From d417a4a48dcab7649009a8577da1b61358846352 Mon Sep 17 00:00:00 2001 From: Effer Date: Sun, 8 Oct 2017 20:28:51 +0200 Subject: [PATCH 03/26] Run button on code editor only --- src/code.c | 27 ++++++++++++++++++++++----- src/code.h | 1 + src/studio.c | 2 +- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/code.c b/src/code.c index e0fd924..73da56e 100644 --- a/src/code.c +++ b/src/code.c @@ -1677,6 +1677,15 @@ static void drawCodeToolbar(Code* code) static const u8 Icons[] = { + 0b00000000, + 0b01000000, + 0b01100000, + 0b01110000, + 0b01100000, + 0b01000000, + 0b00000000, + 0b00000000, + 0b00000000, 0b00111000, 0b01000100, @@ -1708,7 +1717,7 @@ static void drawCodeToolbar(Code* code) enum {Count = sizeof Icons / BITS_IN_BYTE}; enum {Size = 7}; - static const char* Tips[] = {"FIND [ctrl+f]", "GOTO [ctrl+g]", "OUTLINE [ctrl+o]"}; + static const char* Tips[] = {"RUN [ctrl+f]","FIND [ctrl+f]", "GOTO [ctrl+g]", "OUTLINE [ctrl+o]"}; for(s32 i = 0; i < Count; i++) { @@ -1725,14 +1734,21 @@ static void drawCodeToolbar(Code* code) if(checkMouseClick(&rect, SDL_BUTTON_LEFT)) { - s32 mode = TEXT_FIND_MODE + i; + if (i == TEXT_RUN_CODE) + { + runProject(); + } + else + { + s32 mode = TEXT_EDIT_MODE + i; - if(code->mode == mode) code->escape(code); - else setCodeMode(code, mode); + if(code->mode == mode) code->escape(code); + else setCodeMode(code, mode); + } } } - bool active = i == code->mode - TEXT_FIND_MODE; + bool active = i == code->mode - TEXT_EDIT_MODE && i != 0; if(active) code->tic->api.rect(code->tic, rect.x, rect.y, Size, Size, systemColor(tic_color_blue)); @@ -1751,6 +1767,7 @@ static void tick(Code* code) switch(code->mode) { + case TEXT_RUN_CODE: runProject(); break; case TEXT_EDIT_MODE: textEditTick(code); break; case TEXT_FIND_MODE: textFindTick(code); break; case TEXT_GOTO_MODE: textGoToTick(code); break; diff --git a/src/code.h b/src/code.h index 950a625..c05ffba 100644 --- a/src/code.h +++ b/src/code.h @@ -72,6 +72,7 @@ struct Code enum { + TEXT_RUN_CODE, TEXT_EDIT_MODE, TEXT_FIND_MODE, TEXT_GOTO_MODE, diff --git a/src/studio.c b/src/studio.c index a4e0085..0c98848 100644 --- a/src/studio.c +++ b/src/studio.c @@ -1354,7 +1354,7 @@ static void onFullscreen() SDL_SetWindowFullscreen(studio.window, studio.fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0); } -static void runProject() +void runProject() { studio.tic->api.reset(studio.tic); From dd2332737df3f4509c818ce45ea6657c42cd6243 Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Mon, 9 Oct 2017 08:55:15 +0300 Subject: [PATCH 04/26] Revert "Run button on code editor" This reverts commit 75b16b8618dd38b65f01d9cf9507547928dcd436. --- src/code.c | 6 ------ src/studio.c | 13 ++----------- src/studio.h | 1 - 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/src/code.c b/src/code.c index 37d497e..73da56e 100644 --- a/src/code.c +++ b/src/code.c @@ -835,11 +835,6 @@ static void redo(Code* code) update(code); } -static void run() -{ - setStudioMode(TIC_RUN_MODE); -} - static void doTab(Code* code, bool shift) { char* pos = code->cursor.position; @@ -1807,7 +1802,6 @@ static void onStudioEvent(Code* code, StudioEvent event) case TIC_TOOLBAR_PASTE: copyFromClipboard(code); break; case TIC_TOOLBAR_UNDO: undo(code); break; case TIC_TOOLBAR_REDO: redo(code); break; - case TIC_TOOLBAR_RUN: run(); break; } } diff --git a/src/studio.c b/src/studio.c index da4b293..0c98848 100644 --- a/src/studio.c +++ b/src/studio.c @@ -456,20 +456,11 @@ void drawExtrabar(tic_mem* tic) 0b00110000, 0b00000000, 0b00000000, - - 0b00000000, - 0b01000000, - 0b01100000, - 0b01110000, - 0b01100000, - 0b01000000, - 0b00000000, - 0b00000000, }; static const s32 Colors[] = {8, 9, 6, 5, 5}; - static const StudioEvent Events[] = {TIC_TOOLBAR_CUT, TIC_TOOLBAR_COPY, TIC_TOOLBAR_PASTE, TIC_TOOLBAR_UNDO, TIC_TOOLBAR_REDO, TIC_TOOLBAR_RUN}; - static const char* Tips[] = {"CUT [ctrl+x]", "COPY [ctrl+c]", "PASTE [ctrl+v]", "UNDO [ctrl+z]", "REDO [ctrl+y]","RUN [ctrl+r]"}; + static const StudioEvent Events[] = {TIC_TOOLBAR_CUT, TIC_TOOLBAR_COPY, TIC_TOOLBAR_PASTE, TIC_TOOLBAR_UNDO, TIC_TOOLBAR_REDO}; + static const char* Tips[] = {"CUT [ctrl+x]", "COPY [ctrl+c]", "PASTE [ctrl+v]", "UNDO [ctrl+z]", "REDO [ctrl+y]"}; for(s32 i = 0; i < sizeof Icons / BITS_IN_BYTE; i++) { diff --git a/src/studio.h b/src/studio.h index 2b82b68..7c2691d 100644 --- a/src/studio.h +++ b/src/studio.h @@ -172,7 +172,6 @@ typedef enum TIC_TOOLBAR_PASTE, TIC_TOOLBAR_UNDO, TIC_TOOLBAR_REDO, - TIC_TOOLBAR_RUN, } StudioEvent; void setStudioEvent(StudioEvent event); From f00221705bd882898c6498aabbdfc874974a77f2 Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Mon, 9 Oct 2017 08:58:02 +0300 Subject: [PATCH 05/26] Run button on code editor only #331 some fixes --- src/code.c | 12 ++++++------ src/studio.h | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/code.c b/src/code.c index 73da56e..b9e3d28 100644 --- a/src/code.c +++ b/src/code.c @@ -1678,11 +1678,11 @@ static void drawCodeToolbar(Code* code) static const u8 Icons[] = { 0b00000000, - 0b01000000, - 0b01100000, - 0b01110000, - 0b01100000, - 0b01000000, + 0b00100000, + 0b00110000, + 0b00111000, + 0b00110000, + 0b00100000, 0b00000000, 0b00000000, @@ -1717,7 +1717,7 @@ static void drawCodeToolbar(Code* code) enum {Count = sizeof Icons / BITS_IN_BYTE}; enum {Size = 7}; - static const char* Tips[] = {"RUN [ctrl+f]","FIND [ctrl+f]", "GOTO [ctrl+g]", "OUTLINE [ctrl+o]"}; + static const char* Tips[] = {"RUN [ctrl+r]","FIND [ctrl+f]", "GOTO [ctrl+g]", "OUTLINE [ctrl+o]"}; for(s32 i = 0; i < Count; i++) { diff --git a/src/studio.h b/src/studio.h index 7c2691d..960a459 100644 --- a/src/studio.h +++ b/src/studio.h @@ -198,4 +198,5 @@ void playSystemSfx(s32 id); void runGameFromSurf(); void gotoSurf(); -void exitFromGameMenu(); \ No newline at end of file +void exitFromGameMenu(); +void runProject(); \ No newline at end of file From 29abca5e3f535a699f30d73967f7cc93356d3f06 Mon Sep 17 00:00:00 2001 From: Matheus Lessa Date: Fri, 13 Oct 2017 13:25:10 -0300 Subject: [PATCH 06/26] adding goCodeHome and goCodeEnd to use ctrl+home and ctrl+end in the code editor --- .gitignore | 2 + src/code.c | 126 ++++++++++++++++++++++++++++++----------------------- 2 files changed, 73 insertions(+), 55 deletions(-) diff --git a/.gitignore b/.gitignore index 001c65b..d9de875 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,8 @@ *.ipch *.opendb *.suo +sexit +.vscode/ build/uwp/tic/Debug/ build/uwp/tic/Release/ build/uwp/tic/x64/ diff --git a/src/code.c b/src/code.c index b9e3d28..42c5c60 100644 --- a/src/code.c +++ b/src/code.c @@ -72,7 +72,7 @@ static void drawCode(Code* code, bool withCursor) u8* colorPointer = code->colorBuffer; - struct { char* start; char* end; } selection = {SDL_min(code->cursor.selection, code->cursor.position), + struct { char* start; char* end; } selection = {SDL_min(code->cursor.selection, code->cursor.position), SDL_max(code->cursor.selection, code->cursor.position)}; struct { s32 x; s32 y; char symbol; } cursor = {-1, -1, 0}; @@ -155,11 +155,11 @@ static void updateEditor(Code* code) getCursorPosition(code, &column, &line); if(column < code->scroll.x) code->scroll.x = column; - else if(column >= code->scroll.x + TEXT_BUFFER_WIDTH) + else if(column >= code->scroll.x + TEXT_BUFFER_WIDTH) code->scroll.x = column - TEXT_BUFFER_WIDTH + 1; if(line < code->scroll.y) code->scroll.y = line; - else if(line >= code->scroll.y + TEXT_BUFFER_HEIGHT) + else if(line >= code->scroll.y + TEXT_BUFFER_HEIGHT) code->scroll.y = line - TEXT_BUFFER_HEIGHT + 1; code->cursor.delay = TEXT_CURSOR_DELAY; @@ -175,9 +175,9 @@ static void updateEditor(Code* code) size_t codeLen = strlen(code->data); sprintf(status, "%i/%i", (u32)codeLen, TIC_CODE_SIZE); - + memset(code->data + codeLen, '\0', TIC_CODE_SIZE - codeLen); - memcpy(code->status + sizeof code->status - strlen(status) - 1, status, strlen(status)); + memcpy(code->status + sizeof code->status - strlen(status) - 1, status, strlen(status)); } } @@ -203,7 +203,7 @@ static void highlightStrings(Code* code, const char* text, u8* color, char separ memset(colorPtr, getConfig()->theme.code.string, end - start); highlightStrings(code, end, color + (end - text), separator); - } + } } } @@ -265,13 +265,13 @@ static void highlightMoonKeywords(Code* code, u8* color) { const char* text = code->data; - static const char* const MoonKeywords [] = + static const char* const MoonKeywords [] = { - "false", "true", "nil", "return", - "break", "continue", "for", "while", - "if", "else", "elseif", "unless", "switch", - "when", "and", "or", "in", "do", - "not", "super", "try", "catch", + "false", "true", "nil", "return", + "break", "continue", "for", "while", + "if", "else", "elseif", "unless", "switch", + "when", "and", "or", "in", "do", + "not", "super", "try", "catch", "with", "export", "import", "then", "from", "class", "extends", "new" }; @@ -283,7 +283,7 @@ static void highlightLuaKeywords(Code* code, u8* color) { const char* text = code->data; - static const char* const LuaKeywords [] = + static const char* const LuaKeywords [] = { "and", "break", "do", "else", "elseif", "end", "false", "for", "function", "goto", "if", @@ -298,11 +298,11 @@ static void highlightJsKeywords(Code* code, u8* color) { const char* text = code->data; - static const char* const JsKeywords [] = + static const char* const JsKeywords [] = { - "break", "do", "instanceof", "typeof", "case", "else", "new", - "var", "catch", "finally", "return", "void", "continue", "for", - "switch", "while", "debugger", "function", "this", "with", + "break", "do", "instanceof", "typeof", "case", "else", "new", + "var", "catch", "finally", "return", "void", "continue", "for", + "switch", "while", "debugger", "function", "this", "with", "default", "if", "throw", "delete", "in", "try", "const" }; @@ -335,13 +335,13 @@ static void highlightSigns(Code* code, u8* color) { const char* text = code->data; - static const char* const LuaSigns [] = + static const char* const LuaSigns [] = { - "+", "-", "*", "/", "%", "^", "#", - "&", "~", "|", "<<", ">>", "//", - "==", "~=", "<=", ">=", "<", ">", "=", - "(", ")", "{", "}", "[", "]", "::", - ";", ":", ",", ".", "..", "...", + "+", "-", "*", "/", "%", "^", "#", + "&", "~", "|", "<<", ">>", "//", + "==", "~=", "<=", ">=", "<", ">", "=", + "(", ")", "{", "}", "[", "]", "::", + ";", ":", ",", ".", "..", "...", }; for(s32 i = 0; i < COUNT_OF(LuaSigns); i++) @@ -521,7 +521,7 @@ static void setCursorPosition(Code* code, s32 cx, s32 cy) if(y == cy && cx > x) { updateCursorPosition(code, pointer); - return; + return; } x = 0; @@ -567,7 +567,7 @@ static void leftColumn(Code* code) static void rightColumn(Code* code) { if(*code->cursor.position) - { + { code->cursor.position++; updateColumn(code); } @@ -619,6 +619,20 @@ static void goEnd(Code* code) updateColumn(code); } +static void goCodeHome(Code *code) +{ + code->cursor.position = code->data; + + updateColumn(code); +} + +static void goCodeEnd(Code *code) +{ + code->cursor.position = code->data + strlen(code->data); + + updateColumn(code); +} + static void pageUp(Code* code) { s32 column = 0; @@ -878,7 +892,7 @@ static void doTab(Code* code, bool shift) history(code); parseSyntaxColor(code); - + } else inputSymbolBase(code, '\t'); } @@ -890,7 +904,7 @@ static void setFindMode(Code* code) const char* end = SDL_max(code->cursor.position, code->cursor.selection); const char* start = SDL_min(code->cursor.position, code->cursor.selection); size_t len = end - start; - + if(len > 0 && len < sizeof code->popup.text - 1) { memset(code->popup.text, 0, sizeof code->popup.text); @@ -938,7 +952,7 @@ static char* getFuncName(const char* start, char* buffer) memcpy(buffer, start, len); buffer[len] = '\0'; - return buffer; + return buffer; } } @@ -997,7 +1011,7 @@ static void setMoonscriptOutlineMode(Code* code) char filter[STUDIO_TEXT_BUFFER_WIDTH]; strcpy(filter, code->popup.text); SDL_strlwr(filter); - + while(ptr) { ptr = strstr(ptr, FuncString); @@ -1029,7 +1043,7 @@ static void setMoonscriptOutlineMode(Code* code) out++; } } - else + else { out->pos = start; out++; @@ -1076,7 +1090,7 @@ static void setLuaOutlineMode(Code* code) out++; } } - else + else { out->pos = ptr; out++; @@ -1095,7 +1109,7 @@ static void setOutlineMode(Code* code) memset(code->outline.items, 0, OUTLINE_ITEMS_SIZE); code->tic->api.get_script(code->tic) == tic_script_moon - ? setMoonscriptOutlineMode(code) + ? setMoonscriptOutlineMode(code) : setLuaOutlineMode(code); qsort(code->outline.items, OUTLINE_SIZE, sizeof(OutlineItem), funcCompare); @@ -1199,7 +1213,7 @@ static void processKeydown(Code* code, SDL_Keycode keycode) if(!(keymod & KMOD_SHIFT)) code->cursor.selection = NULL; else if(code->cursor.selection == NULL) code->cursor.selection = code->cursor.position; } - + if(keymod & TIC_MOD_CTRL) { if(keymod & KMOD_CTRL) @@ -1228,6 +1242,8 @@ static void processKeydown(Code* code, SDL_Keycode keycode) case SDLK_g: setCodeMode(code, TEXT_GOTO_MODE); break; case SDLK_o: setCodeMode(code, TEXT_OUTLINE_MODE); break; case SDLK_SLASH: commentLine(code); break; + case SDLK_HOME: goCodeHome(code); break; + case SDLK_END: goCodeEnd(code); break; } } else if(keymod & KMOD_ALT) @@ -1319,7 +1335,7 @@ static void processMouse(Code* code) code->cursor.position = position; } else if(!code->cursor.mouseDownPosition) - { + { code->cursor.selection = code->cursor.position; code->cursor.mouseDownPosition = code->cursor.position; } @@ -1352,7 +1368,7 @@ static void textEditTick(Code* code) switch(event->type) { case SDL_MOUSEWHEEL: - { + { enum{Scroll = 3}; s32 delta = event->wheel.y > 0 ? -Scroll : Scroll; @@ -1368,11 +1384,11 @@ static void textEditTick(Code* code) #if defined(__LINUX__) if(!(SDL_GetModState() & KMOD_LALT)) -#endif - +#endif + if(strlen(event->text.text) == 1) { - + inputSymbol(code, *event->text.text); updateEditor(code); @@ -1425,7 +1441,7 @@ static char* upStrStr(const char* start, const char* from, const char* substr) return (char*)ptr; ptr--; - } + } } return NULL; @@ -1446,9 +1462,9 @@ static void textFindTick(Code* code) case SDL_KEYDOWN: switch(event->key.keysym.sym) { - case SDLK_RETURN: + case SDLK_RETURN: setCodeMode(code, TEXT_EDIT_MODE); - break; + break; case SDLK_UP: case SDLK_LEFT: case SDLK_DOWN: @@ -1474,7 +1490,7 @@ static void textFindTick(Code* code) } break; case SDL_TEXTINPUT: - if(strlen(event->text.text) == 1) + if(strlen(event->text.text) == 1) { if(strlen(code->popup.text) + 1 < sizeof code->popup.text) { @@ -1523,7 +1539,7 @@ static void textGoToTick(Code* code) case SDL_KEYDOWN: switch(event->key.keysym.sym) { - case SDLK_RETURN: + case SDLK_RETURN: if(*code->popup.text) updateGotoCode(code); @@ -1540,7 +1556,7 @@ static void textGoToTick(Code* code) } break; case SDL_TEXTINPUT: - if(strlen(event->text.text) == 1) + if(strlen(event->text.text) == 1) { char sym = *event->text.text; @@ -1558,7 +1574,7 @@ static void textGoToTick(Code* code) code->tic->api.clear(code->tic, getConfig()->theme.code.bg); if(code->jump.line >= 0) - code->tic->api.rect(code->tic, 0, (code->jump.line - code->scroll.y) * TIC_FONT_HEIGHT + TOOLBAR_SIZE-1, + code->tic->api.rect(code->tic, 0, (code->jump.line - code->scroll.y) * TIC_FONT_HEIGHT + TOOLBAR_SIZE-1, TIC80_WIDTH, TIC_FONT_HEIGHT+1, getConfig()->theme.code.select); drawCode(code, false); @@ -1583,7 +1599,7 @@ static void drawOutlineBar(Code* code, s32 x, s32 y) { code->outline.index = mx; updateOutlineCode(code); - + } if(checkMouseClick(&rect, SDL_BUTTON_LEFT)) @@ -1599,14 +1615,14 @@ static void drawOutlineBar(Code* code, s32 x, s32 y) if(ptr->pos) { - code->tic->api.rect(code->tic, rect.x - 1, rect.y + code->outline.index*STUDIO_TEXT_HEIGHT, + code->tic->api.rect(code->tic, rect.x - 1, rect.y + code->outline.index*STUDIO_TEXT_HEIGHT, rect.w + 1, TIC_FONT_HEIGHT + 1, systemColor(tic_color_red)); while(ptr->pos) { code->tic->api.fixed_text(code->tic, ptr->name, x, y, systemColor(tic_color_white)); ptr++; y += STUDIO_TEXT_HEIGHT; - } + } } else code->tic->api.fixed_text(code->tic, "(empty)", x, y, systemColor(tic_color_white)); } @@ -1621,21 +1637,21 @@ static void textOutlineTick(Code* code) case SDL_KEYDOWN: switch(event->key.keysym.sym) { - case SDLK_UP: + case SDLK_UP: if(code->outline.index > 0) { code->outline.index--; updateOutlineCode(code); } break; - case SDLK_DOWN: + case SDLK_DOWN: if(code->outline.index < OUTLINE_SIZE - 1 && code->outline.items[code->outline.index + 1].pos) { code->outline.index++; updateOutlineCode(code); } break; - case SDLK_RETURN: + case SDLK_RETURN: updateOutlineCode(code); setCodeMode(code, TEXT_EDIT_MODE); break; @@ -1650,7 +1666,7 @@ static void textOutlineTick(Code* code) } break; case SDL_TEXTINPUT: - if(strlen(event->text.text) == 1) + if(strlen(event->text.text) == 1) { if(strlen(code->popup.text) + 1 < sizeof code->popup.text) { @@ -1675,7 +1691,7 @@ static void drawCodeToolbar(Code* code) { code->tic->api.rect(code->tic, 0, 0, TIC80_WIDTH, TOOLBAR_SIZE-1, systemColor(tic_color_white)); - static const u8 Icons[] = + static const u8 Icons[] = { 0b00000000, 0b00100000, @@ -1827,12 +1843,12 @@ void initCode(Code* code, tic_mem* tic) .cursorHistory = NULL, .mode = TEXT_EDIT_MODE, .jump = {.line = -1}, - .popup = + .popup = { .prevPos = NULL, .prevSel = NULL, }, - .outline = + .outline = { .items = code->outline.items, .index = 0, From f6c884cd7e0bac7e854231e8c8bbad1b296c90e9 Mon Sep 17 00:00:00 2001 From: Anthony Camboni Date: Sun, 15 Oct 2017 11:06:38 +0200 Subject: [PATCH 07/26] Ensure tile pos is always visible in map editor The tile position label was not entirely visible when hovering the tiles near the top/right of the screen. This modification ensures that the label is always visible by moving it to the opposite side of the tile if there is not enough space to display it on the default position. --- src/map.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/map.c b/src/map.c index ee3b4b4..be701c3 100644 --- a/src/map.c +++ b/src/map.c @@ -411,12 +411,16 @@ static void drawCursorPos(Map* map, s32 x, s32 y) sprintf(pos, "%03i:%03i", tx, ty); - x += (TIC_SPRITESIZE + 3); - y -= (TIC_FONT_HEIGHT + 2); + s32 width = map->tic->api.text(map->tic, pos, TIC80_WIDTH, 0, systemColor(tic_color_gray)); - s32 width = map->tic->api.text(map->tic, pos, x, y, systemColor(tic_color_gray)); - map->tic->api.rect(map->tic, x - 1, y - 1, width + 1, TIC_FONT_HEIGHT + 1, systemColor(tic_color_white)); - map->tic->api.text(map->tic, pos, x, y, systemColor(tic_color_light_blue)); + s32 px = x + (TIC_SPRITESIZE + 3); + if(px + width >= TIC80_WIDTH) px = x - (width + 2); + + s32 py = y - (TIC_FONT_HEIGHT + 2); + if(py <= TOOLBAR_SIZE) py = y + (TIC_SPRITESIZE + 3); + + map->tic->api.rect(map->tic, px - 1, py - 1, width + 1, TIC_FONT_HEIGHT + 1, systemColor(tic_color_white)); + map->tic->api.text(map->tic, pos, px, py, systemColor(tic_color_light_blue)); } static void setMapSprite(Map* map, s32 x, s32 y) From 392e006a4acd68b49f1a5d046ff053b00a660e71 Mon Sep 17 00:00:00 2001 From: Matheus Lessa Date: Mon, 16 Oct 2017 01:03:05 -0200 Subject: [PATCH 08/26] first version working with no option to disable live reloading --- src/console.c | 192 +++++++++++++++++++++++++++++--------------------- src/console.h | 10 ++- src/studio.c | 161 ++++++++++++++++++++++-------------------- 3 files changed, 206 insertions(+), 157 deletions(-) diff --git a/src/console.c b/src/console.c index 967a980..39f0133 100644 --- a/src/console.c +++ b/src/console.c @@ -122,7 +122,7 @@ static void consolePrint(Console* console, const char* text, u8 color) console->cursor.x = 0; console->cursor.y++; } - else + else { s32 offset = console->cursor.x + console->cursor.y * CONSOLE_BUFFER_WIDTH; *(console->buffer + offset) = symbol; @@ -182,7 +182,7 @@ static void drawCursor(Console* console, s32 x, s32 y, u8 symbol) if(inverse) console->tic->api.rect(console->tic, x-1, y-1, TIC_FONT_WIDTH+1, TIC_FONT_HEIGHT+1, CONSOLE_CURSOR_COLOR); - + console->tic->api.draw_char(console->tic, symbol, x, y, inverse ? TIC_COLOR_BG : CONSOLE_FRONT_TEXT_COLOR); } @@ -260,7 +260,7 @@ static void processConsoleDel(Console* console) { char* pos = console->inputBuffer + console->inputPosition; size_t size = strlen(pos); - memmove(pos, pos + 1, size); + memmove(pos, pos + 1, size); } static void processConsoleBackspace(Console* console) @@ -269,7 +269,7 @@ static void processConsoleBackspace(Console* console) { console->inputPosition--; - processConsoleDel(console); + processConsoleDel(console); } } @@ -322,7 +322,7 @@ static bool onConsoleLoadSectionCommand(Console* console, const char* param) if(param) { - static const char* Sections[] = + static const char* Sections[] = { "sprites", "map", @@ -416,21 +416,21 @@ static void* getDemoCart(Console* console, tic_script_lang script, s32* size) return data; } - static const u8 LuaDemoRom[] = + static const u8 LuaDemoRom[] = { #include "../bin/assets/luademo.tic.dat" }; - static const u8 JsDemoRom[] = + static const u8 JsDemoRom[] = { #include "../bin/assets/jsdemo.tic.dat" }; - static const u8 MoonDemoRom[] = + static const u8 MoonDemoRom[] = { #include "../bin/assets/moondemo.tic.dat" }; - + const u8* demo = NULL; s32 romSize = 0; @@ -467,7 +467,7 @@ static void onConsoleLoadDemoCommandConfirmed(Console* console, const char* para s32 size = 0; console->showGameMenu = false; - + if(strcmp(param, DefaultLuaTicPath) == 0) data = getDemoCart(console, tic_script_lua, &size); else if(strcmp(param, DefaultMoonTicPath) == 0) @@ -499,7 +499,7 @@ static void onConsoleLoadCommandConfirmed(Console* console, const char* param) s32 size = 0; const char* name = getRomName(param); - void* data = strcmp(name, CONFIG_TIC_PATH) == 0 + void* data = strcmp(name, CONFIG_TIC_PATH) == 0 ? fsLoadRootFile(console->fs, name, &size) : fsLoadFile(console->fs, name, &size); @@ -568,7 +568,7 @@ static void onConsoleLoadDemoCommand(Console* console, const char* param) { if(studioCartChanged()) { - static const char* Rows[] = + static const char* Rows[] = { "YOU HAVE", "UNSAVED CHANGES", @@ -589,7 +589,7 @@ static void onConsoleLoadCommand(Console* console, const char* param) { if(studioCartChanged()) { - static const char* Rows[] = + static const char* Rows[] = { "YOU HAVE", "UNSAVED CHANGES", @@ -615,7 +615,7 @@ static void loadDemo(Console* console, tic_script_lang script) { loadRom(console->tic, data, size, false); - SDL_free(data); + SDL_free(data); } SDL_memset(console->romName, 0, sizeof console->romName); @@ -651,7 +651,7 @@ static void onConsoleNewCommand(Console* console, const char* param) { if(studioCartChanged()) { - static const char* Rows[] = + static const char* Rows[] = { "YOU HAVE", "UNSAVED CHANGES", @@ -779,42 +779,42 @@ static void installDemoCart(FileSystem* fs, const char* name, const void* cart, static void onConsoleInstallDemosCommand(Console* console, const char* param) { - static const u8 DemoFire[] = + static const u8 DemoFire[] = { #include "../bin/assets/fire.tic.dat" }; - static const u8 DemoP3D[] = + static const u8 DemoP3D[] = { #include "../bin/assets/p3d.tic.dat" }; - static const u8 DemoSFX[] = + static const u8 DemoSFX[] = { #include "../bin/assets/sfx.tic.dat" }; - static const u8 DemoPalette[] = + static const u8 DemoPalette[] = { #include "../bin/assets/palette.tic.dat" }; - static const u8 DemoFont[] = + static const u8 DemoFont[] = { #include "../bin/assets/font.tic.dat" }; - static const u8 DemoMusic[] = + static const u8 DemoMusic[] = { #include "../bin/assets/music.tic.dat" }; - static const u8 GameQuest[] = + static const u8 GameQuest[] = { #include "../bin/assets/quest.tic.dat" }; - static const u8 GameTetris[] = + static const u8 GameTetris[] = { #include "../bin/assets/tetris.tic.dat" }; @@ -942,7 +942,7 @@ static void onImportCover(const char* name, const void* buffer, size_t size, voi printLine(console); printBack(console, name); - printBack(console, " successfully imported"); + printBack(console, " successfully imported"); } else printError(console, "\ncover image too big :("); } @@ -950,9 +950,9 @@ static void onImportCover(const char* name, const void* buffer, size_t size, voi gif_close(image); } - else printError(console, "\nfile importing error :("); + else printError(console, "\nfile importing error :("); } - else printBack(console, "\nonly .gif files can be imported :|"); + else printBack(console, "\nonly .gif files can be imported :|"); } else printBack(console, "\nfile not imported :|"); @@ -1006,7 +1006,7 @@ static void onImportSprites(const char* name, const void* buffer, size_t size, v } else printError(console, "\nfile importing error :("); } - else printBack(console, "\nonly .gif files can be imported :|"); + else printBack(console, "\nonly .gif files can be imported :|"); } else printBack(console, "\nfile not imported :|"); @@ -1091,7 +1091,7 @@ static void exportCover(Console* console) else { printBack(console, "\ncover image is empty, run game and\npress [F7] to assign cover image"); - commandDone(console); + commandDone(console); } } @@ -1215,7 +1215,7 @@ typedef struct const char* cartName; } AppFileReadParam; -typedef struct +typedef struct { u8* data; size_t size; @@ -1272,7 +1272,7 @@ static void onConsoleExportHtmlCommand(Console* console, const char* name) writeMemoryString(&output, "