From e4ef780f286525a5a4b2f56016155102ac847a4e Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Mon, 12 Feb 2018 19:16:37 +0300 Subject: [PATCH] no message --- src/code.c | 94 +++++++++++++++++++++++++-------------------------- src/console.c | 22 ++++++------ src/studio.c | 62 ++++++++++++++++----------------- src/studio.h | 4 +-- 4 files changed, 91 insertions(+), 91 deletions(-) diff --git a/src/code.c b/src/code.c index f14f47d..a1e4206 100644 --- a/src/code.c +++ b/src/code.c @@ -884,14 +884,14 @@ static void processKeyboard(Code* code) bool ctrl = tic->api.key(tic, tic_key_ctrl); bool alt = tic->api.key(tic, tic_key_alt); - if(isKeyWasDown(tic_key_up) - || isKeyWasDown(tic_key_down) - || isKeyWasDown(tic_key_left) - || isKeyWasDown(tic_key_right) - || isKeyWasDown(tic_key_home) - || isKeyWasDown(tic_key_end) - || isKeyWasDown(tic_key_pageup) - || isKeyWasDown(tic_key_pagedown)) + if(isKeyBeenPressed(tic_key_up) + || isKeyBeenPressed(tic_key_down) + || isKeyBeenPressed(tic_key_left) + || isKeyBeenPressed(tic_key_right) + || isKeyBeenPressed(tic_key_home) + || isKeyBeenPressed(tic_key_end) + || isKeyBeenPressed(tic_key_pageup) + || isKeyBeenPressed(tic_key_pagedown)) { if(!shift) code->cursor.selection = NULL; else if(code->cursor.selection == NULL) code->cursor.selection = code->cursor.position; @@ -901,9 +901,9 @@ static void processKeyboard(Code* code) { if(ctrl) { - if(isKeyWasDown(tic_key_left)) leftWord(code); - else if(isKeyWasDown(tic_key_right)) rightWord(code); - else if(isKeyWasDown(tic_key_tab)) doTab(code, shift, ctrl); + if(isKeyBeenPressed(tic_key_left)) leftWord(code); + else if(isKeyBeenPressed(tic_key_right)) rightWord(code); + else if(isKeyBeenPressed(tic_key_tab)) doTab(code, shift, ctrl); } // else if(keymod & KMOD_GUI) // { @@ -914,35 +914,35 @@ static void processKeyboard(Code* code) // } // } - if(isKeyWasDown(tic_key_a)) selectAll(code); - else if(isKeyWasDown(tic_key_z)) undo(code); - else if(isKeyWasDown(tic_key_y)) redo(code); - else if(isKeyWasDown(tic_key_f)) setCodeMode(code, TEXT_FIND_MODE); - else if(isKeyWasDown(tic_key_g)) setCodeMode(code, TEXT_GOTO_MODE); - else if(isKeyWasDown(tic_key_o)) setCodeMode(code, TEXT_OUTLINE_MODE); - else if(isKeyWasDown(tic_key_slash)) commentLine(code); - else if(isKeyWasDown(tic_key_home)) goCodeHome(code); - else if(isKeyWasDown(tic_key_end)) goCodeEnd(code); + if(isKeyBeenPressed(tic_key_a)) selectAll(code); + else if(isKeyBeenPressed(tic_key_z)) undo(code); + else if(isKeyBeenPressed(tic_key_y)) redo(code); + else if(isKeyBeenPressed(tic_key_f)) setCodeMode(code, TEXT_FIND_MODE); + else if(isKeyBeenPressed(tic_key_g)) setCodeMode(code, TEXT_GOTO_MODE); + else if(isKeyBeenPressed(tic_key_o)) setCodeMode(code, TEXT_OUTLINE_MODE); + else if(isKeyBeenPressed(tic_key_slash)) commentLine(code); + else if(isKeyBeenPressed(tic_key_home)) goCodeHome(code); + else if(isKeyBeenPressed(tic_key_end)) goCodeEnd(code); } else if(alt) { - if(isKeyWasDown(tic_key_left)) leftWord(code); - else if(isKeyWasDown(tic_key_right)) rightWord(code); + if(isKeyBeenPressed(tic_key_left)) leftWord(code); + else if(isKeyBeenPressed(tic_key_right)) rightWord(code); } else { - if(isKeyWasDown(tic_key_up)) upLine(code); - else if(isKeyWasDown(tic_key_down)) downLine(code); - else if(isKeyWasDown(tic_key_left)) leftColumn(code); - else if(isKeyWasDown(tic_key_right)) rightColumn(code); - else if(isKeyWasDown(tic_key_home)) goHome(code); - else if(isKeyWasDown(tic_key_end)) goEnd(code); - else if(isKeyWasDown(tic_key_pageup)) pageUp(code); - else if(isKeyWasDown(tic_key_pagedown)) pageDown(code); - else if(isKeyWasDown(tic_key_delete)) deleteChar(code); - else if(isKeyWasDown(tic_key_backspace)) backspaceChar(code); - else if(isKeyWasDown(tic_key_return)) newLine(code); - else if(isKeyWasDown(tic_key_tab)) doTab(code, shift, ctrl); + if(isKeyBeenPressed(tic_key_up)) upLine(code); + else if(isKeyBeenPressed(tic_key_down)) downLine(code); + else if(isKeyBeenPressed(tic_key_left)) leftColumn(code); + else if(isKeyBeenPressed(tic_key_right)) rightColumn(code); + else if(isKeyBeenPressed(tic_key_home)) goHome(code); + else if(isKeyBeenPressed(tic_key_end)) goEnd(code); + else if(isKeyBeenPressed(tic_key_pageup)) pageUp(code); + else if(isKeyBeenPressed(tic_key_pagedown)) pageDown(code); + else if(isKeyBeenPressed(tic_key_delete)) deleteChar(code); + else if(isKeyBeenPressed(tic_key_backspace)) backspaceChar(code); + else if(isKeyBeenPressed(tic_key_return)) newLine(code); + else if(isKeyBeenPressed(tic_key_tab)) doTab(code, shift, ctrl); } updateEditor(code); @@ -1124,22 +1124,22 @@ static char* downStrStr(const char* start, const char* from, const char* substr) static void textFindTick(Code* code) { - if(isKeyWasDown(tic_key_return)) setCodeMode(code, TEXT_EDIT_MODE); - else if(isKeyWasDown(tic_key_up) - || isKeyWasDown(tic_key_down) - || isKeyWasDown(tic_key_left) - || isKeyWasDown(tic_key_right)) + if(isKeyBeenPressed(tic_key_return)) setCodeMode(code, TEXT_EDIT_MODE); + else if(isKeyBeenPressed(tic_key_up) + || isKeyBeenPressed(tic_key_down) + || isKeyBeenPressed(tic_key_left) + || isKeyBeenPressed(tic_key_right)) { if(*code->popup.text) { - bool reverse = isKeyWasDown(tic_key_up) || isKeyWasDown(tic_key_left); + bool reverse = isKeyBeenPressed(tic_key_up) || isKeyBeenPressed(tic_key_left); char* (*func)(const char*, const char*, const char*) = reverse ? upStrStr : downStrStr; char* from = reverse ? MIN(code->cursor.position, code->cursor.selection) : MAX(code->cursor.position, code->cursor.selection); char* pos = func(code->src, from, code->popup.text); updateFindCode(code, pos); } } - else if(isKeyWasDown(tic_key_backspace)) + else if(isKeyBeenPressed(tic_key_backspace)) { if(*code->popup.text) { @@ -1190,14 +1190,14 @@ static void textGoToTick(Code* code) { tic_mem* tic = code->tic; - if(isKeyWasDown(tic_key_return)) + if(isKeyBeenPressed(tic_key_return)) { if(*code->popup.text) updateGotoCode(code); setCodeMode(code, TEXT_EDIT_MODE); } - else if(isKeyWasDown(tic_key_backspace)) + else if(isKeyBeenPressed(tic_key_backspace)) { if(*code->popup.text) { @@ -1276,7 +1276,7 @@ static void drawOutlineBar(Code* code, s32 x, s32 y) static void textOutlineTick(Code* code) { - if(isKeyWasDown(tic_key_up)) + if(isKeyBeenPressed(tic_key_up)) { if(code->outline.index > 0) { @@ -1284,7 +1284,7 @@ static void textOutlineTick(Code* code) updateOutlineCode(code); } } - else if(isKeyWasDown(tic_key_down)) + else if(isKeyBeenPressed(tic_key_down)) { if(code->outline.index < OUTLINE_SIZE - 1 && code->outline.items[code->outline.index + 1].pos) { @@ -1292,12 +1292,12 @@ static void textOutlineTick(Code* code) updateOutlineCode(code); } } - else if(isKeyWasDown(tic_key_return)) + else if(isKeyBeenPressed(tic_key_return)) { updateOutlineCode(code); setCodeMode(code, TEXT_EDIT_MODE); } - else if(isKeyWasDown(tic_key_backspace)) + else if(isKeyBeenPressed(tic_key_backspace)) { if(*code->popup.text) { diff --git a/src/console.c b/src/console.c index cca7117..1a3476a 100644 --- a/src/console.c +++ b/src/console.c @@ -2571,28 +2571,28 @@ static void tick(Console* console) } { - if(isKeyWasDown(tic_key_up)) onHistoryUp(console); - else if(isKeyWasDown(tic_key_down)) onHistoryDown(console); - else if(isKeyWasDown(tic_key_left)) + if(isKeyBeenPressed(tic_key_up)) onHistoryUp(console); + else if(isKeyBeenPressed(tic_key_down)) onHistoryDown(console); + else if(isKeyBeenPressed(tic_key_left)) { if(console->inputPosition > 0) console->inputPosition--; } - else if(isKeyWasDown(tic_key_right)) + else if(isKeyBeenPressed(tic_key_right)) { console->inputPosition++; size_t len = strlen(console->inputBuffer); if(console->inputPosition > len) console->inputPosition = len; } - else if(isKeyWasDown(tic_key_return)) processConsoleCommand(console); - else if(isKeyWasDown(tic_key_backspace)) processConsoleBackspace(console); - else if(isKeyWasDown(tic_key_delete)) processConsoleDel(console); - else if(isKeyWasDown(tic_key_home)) processConsoleHome(console); - else if(isKeyWasDown(tic_key_end)) processConsoleEnd(console); - else if(isKeyWasDown(tic_key_tab)) processConsoleTab(console); + else if(isKeyBeenPressed(tic_key_return)) processConsoleCommand(console); + else if(isKeyBeenPressed(tic_key_backspace)) processConsoleBackspace(console); + else if(isKeyBeenPressed(tic_key_delete)) processConsoleDel(console); + else if(isKeyBeenPressed(tic_key_home)) processConsoleHome(console); + else if(isKeyBeenPressed(tic_key_end)) processConsoleEnd(console); + else if(isKeyBeenPressed(tic_key_tab)) processConsoleTab(console); - if(isAnyKeyWasDown()) + if(isAnyKeyBeenPressed()) { scrollConsole(console); console->cursor.delay = CONSOLE_CURSOR_DELAY; diff --git a/src/studio.c b/src/studio.c index d1b92df..83e71e5 100644 --- a/src/studio.c +++ b/src/studio.c @@ -349,13 +349,13 @@ char getKeyboardText() return 0; } -bool isKeyWasDown(tic_key key) +bool isKeyBeenPressed(tic_key key) { tic_mem* tic = studioImpl.studio.tic; return tic->api.keyp(tic, key, KEYBOARD_HOLD, KEYBOARD_PERIOD); } -bool isAnyKeyWasDown() +bool isAnyKeyBeenPressed() { tic_mem* tic = studioImpl.studio.tic; @@ -909,14 +909,14 @@ ClipboardEvent getClipboardEvent() if(ctrl) { - if(isKeyWasDown(tic_key_insert) || isKeyWasDown(tic_key_c)) return TIC_CLIPBOARD_COPY; - else if(isKeyWasDown(tic_key_x)) return TIC_CLIPBOARD_CUT; - else if(isKeyWasDown(tic_key_v)) return TIC_CLIPBOARD_PASTE; + if(isKeyBeenPressed(tic_key_insert) || isKeyBeenPressed(tic_key_c)) return TIC_CLIPBOARD_COPY; + else if(isKeyBeenPressed(tic_key_x)) return TIC_CLIPBOARD_CUT; + else if(isKeyBeenPressed(tic_key_v)) return TIC_CLIPBOARD_PASTE; } else if(shift) { - if(isKeyWasDown(tic_key_delete)) return TIC_CLIPBOARD_CUT; - else if(isKeyWasDown(tic_key_insert)) return TIC_CLIPBOARD_PASTE; + if(isKeyBeenPressed(tic_key_delete)) return TIC_CLIPBOARD_CUT; + else if(isKeyBeenPressed(tic_key_insert)) return TIC_CLIPBOARD_PASTE; } return TIC_CLIPBOARD_NONE; @@ -1790,7 +1790,7 @@ static void takeScreenshot() } } -static inline bool isKeyWasDownOnce(s32 key) +static inline bool isKeyBeenPressedOnce(s32 key) { tic_mem* tic = studioImpl.studio.tic; @@ -1848,13 +1848,13 @@ static void processShortcuts() if(alt) { - if(isKeyWasDownOnce(tic_key_grave)) setStudioMode(TIC_CONSOLE_MODE); - else if(isKeyWasDownOnce(tic_key_1)) setStudioMode(TIC_CODE_MODE); - else if(isKeyWasDownOnce(tic_key_2)) setStudioMode(TIC_SPRITE_MODE); - else if(isKeyWasDownOnce(tic_key_3)) setStudioMode(TIC_MAP_MODE); - else if(isKeyWasDownOnce(tic_key_4)) setStudioMode(TIC_SFX_MODE); - else if(isKeyWasDownOnce(tic_key_5)) setStudioMode(TIC_MUSIC_MODE); - else if(isKeyWasDownOnce(tic_key_return)) goFullscreen(); + if(isKeyBeenPressedOnce(tic_key_grave)) setStudioMode(TIC_CONSOLE_MODE); + else if(isKeyBeenPressedOnce(tic_key_1)) setStudioMode(TIC_CODE_MODE); + else if(isKeyBeenPressedOnce(tic_key_2)) setStudioMode(TIC_SPRITE_MODE); + else if(isKeyBeenPressedOnce(tic_key_3)) setStudioMode(TIC_MAP_MODE); + else if(isKeyBeenPressedOnce(tic_key_4)) setStudioMode(TIC_SFX_MODE); + else if(isKeyBeenPressedOnce(tic_key_5)) setStudioMode(TIC_MUSIC_MODE); + else if(isKeyBeenPressedOnce(tic_key_return)) goFullscreen(); // switch(event->keysym.sym) // { @@ -1869,12 +1869,12 @@ static void processShortcuts() } else if(ctrl) { - if(isKeyWasDownOnce(tic_key_pageup)) changeStudioMode(-1); - else if(isKeyWasDownOnce(tic_key_pagedown)) changeStudioMode(1); - else if(isKeyWasDownOnce(tic_key_q)) exitStudio(); - else if(isKeyWasDownOnce(tic_key_r)) runProject(); - else if(isKeyWasDownOnce(tic_key_return)) runProject(); - else if(isKeyWasDownOnce(tic_key_s)) saveProject(); + if(isKeyBeenPressedOnce(tic_key_pageup)) changeStudioMode(-1); + else if(isKeyBeenPressedOnce(tic_key_pagedown)) changeStudioMode(1); + else if(isKeyBeenPressedOnce(tic_key_q)) exitStudio(); + else if(isKeyBeenPressedOnce(tic_key_r)) runProject(); + else if(isKeyBeenPressedOnce(tic_key_return)) runProject(); + else if(isKeyBeenPressedOnce(tic_key_s)) saveProject(); // switch(event->keysym.sym) @@ -1885,18 +1885,18 @@ static void processShortcuts() } else { - if(isKeyWasDownOnce(tic_key_f1)) setStudioMode(TIC_CODE_MODE); - else if(isKeyWasDownOnce(tic_key_f2)) setStudioMode(TIC_SPRITE_MODE); - else if(isKeyWasDownOnce(tic_key_f3)) setStudioMode(TIC_MAP_MODE); - else if(isKeyWasDownOnce(tic_key_f4)) setStudioMode(TIC_SFX_MODE); - else if(isKeyWasDownOnce(tic_key_f5)) setStudioMode(TIC_MUSIC_MODE); - else if(isKeyWasDownOnce(tic_key_f7)) setCoverImage(); - else if(isKeyWasDownOnce(tic_key_f8)) takeScreenshot(); + if(isKeyBeenPressedOnce(tic_key_f1)) setStudioMode(TIC_CODE_MODE); + else if(isKeyBeenPressedOnce(tic_key_f2)) setStudioMode(TIC_SPRITE_MODE); + else if(isKeyBeenPressedOnce(tic_key_f3)) setStudioMode(TIC_MAP_MODE); + else if(isKeyBeenPressedOnce(tic_key_f4)) setStudioMode(TIC_SFX_MODE); + else if(isKeyBeenPressedOnce(tic_key_f5)) setStudioMode(TIC_MUSIC_MODE); + else if(isKeyBeenPressedOnce(tic_key_f7)) setCoverImage(); + else if(isKeyBeenPressedOnce(tic_key_f8)) takeScreenshot(); #if !defined(__EMSCRIPTEN__) - else if(isKeyWasDownOnce(tic_key_f9)) startVideoRecord(); + else if(isKeyBeenPressedOnce(tic_key_f9)) startVideoRecord(); #endif - else if(isKeyWasDownOnce(tic_key_f11)) goFullscreen(); - else if(isKeyWasDownOnce(tic_key_escape)) + else if(isKeyBeenPressedOnce(tic_key_f11)) goFullscreen(); + else if(isKeyBeenPressedOnce(tic_key_escape)) { Code* code = studioImpl.editor[studioImpl.bank.index.code].code; diff --git a/src/studio.h b/src/studio.h index cf914ad..68d6f07 100644 --- a/src/studio.h +++ b/src/studio.h @@ -241,8 +241,8 @@ TIC80_API void studioTick(void* pixels); TIC80_API void studioClose(); char getKeyboardText(); -bool isKeyWasDown(tic_key key); -bool isAnyKeyWasDown(); +bool isKeyBeenPressed(tic_key key); +bool isAnyKeyBeenPressed(); void setClipboardText(const char* text); bool hasClipboardText();