From 2c8b10a0c24051d380bc90c7bbfbebcae522a5ba Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Mon, 11 Dec 2017 12:46:52 +0300 Subject: [PATCH] some small fixes for #456 --- src/studio.c | 38 ++++++++++++++++---------------------- src/studio.h | 1 - 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/src/studio.c b/src/studio.c index 6405938..4f89b80 100644 --- a/src/studio.c +++ b/src/studio.c @@ -373,21 +373,16 @@ void str2buf(const char* str, s32 size, void* buf, bool flip) } } -void removeWhiteSpaces(char* str) +static void removeWhiteSpaces(char* str) { - int i = 0; - int len = strlen(str); - - for (int j = 0; j < len; j++) { - if (!isspace(str[j])) { - str[i] = str[j]; - i++; - } - } - - if (i < len - 1) { - str[i] = '\0'; - } + s32 i = 0; + s32 len = strlen(str); + + for (s32 j = 0; j < len; j++) + if(!SDL_isspace(str[j])) + str[i++] = str[j]; + + str[i] = '\0'; } bool fromClipboard(void* data, s32 size, bool flip, bool remove_white_spaces) @@ -400,10 +395,9 @@ bool fromClipboard(void* data, s32 size, bool flip, bool remove_white_spaces) if(clipboard) { - if (remove_white_spaces) - removeWhiteSpaces(clipboard); - - + if (remove_white_spaces) + removeWhiteSpaces(clipboard); + bool valid = strlen(clipboard) == size * 2; if(valid) str2buf(clipboard, strlen(clipboard), data, flip); @@ -802,7 +796,7 @@ void setStudioMode(EditorMode mode) EditorMode prev = studio.mode; if(prev == TIC_RUN_MODE) - studio.tic->api.pause(studio.tic); + studio.tic->api.pause(studio.tic); if(mode != TIC_RUN_MODE) studio.tic->api.reset(studio.tic); @@ -838,8 +832,8 @@ void setStudioMode(EditorMode mode) else if ((prev == TIC_MENU_MODE || prev == TIC_SURF_MODE) && studio.mode != TIC_RUN_MODE) enableScreenTextInput(); - if(SDL_HasScreenKeyboardSupport() && - (studio.mode == TIC_RUN_MODE || studio.mode == TIC_SURF_MODE || studio.mode == TIC_MENU_MODE)) + if(SDL_HasScreenKeyboardSupport() && + (studio.mode == TIC_RUN_MODE || studio.mode == TIC_SURF_MODE || studio.mode == TIC_MENU_MODE)) SDL_StopTextInput(); } } @@ -1998,7 +1992,7 @@ static void blitTexture() SDL_Rect srcRect = {Left, Top, TIC80_WIDTH, TIC80_HEIGHT}; - SDL_RenderCopy(studio.renderer, studio.texture, &srcRect, &rect); + SDL_RenderCopy(studio.renderer, studio.texture, &srcRect, &rect); } } diff --git a/src/studio.h b/src/studio.h index d285898..59ce7f8 100644 --- a/src/studio.h +++ b/src/studio.h @@ -154,7 +154,6 @@ void exitStudio(); u32 unzip(u8** dest, const u8* source, size_t size); void str2buf(const char* str, s32 size, void* buf, bool flip); -void removeWhiteSpaces(char* str); void toClipboard(const void* data, s32 size, bool flip); bool fromClipboard(void* data, s32 size, bool flip, bool remove_white_spaces);