Merge pull request #331 from Effer/Run-Button-Code-Only

Run button on code editor only
This commit is contained in:
Vadim Grigoruk 2017-10-09 08:53:16 +03:00 committed by GitHub
commit 7033061973
3 changed files with 24 additions and 6 deletions

View File

@ -1682,6 +1682,15 @@ static void drawCodeToolbar(Code* code)
static const u8 Icons[] = static const u8 Icons[] =
{ {
0b00000000,
0b01000000,
0b01100000,
0b01110000,
0b01100000,
0b01000000,
0b00000000,
0b00000000,
0b00000000, 0b00000000,
0b00111000, 0b00111000,
0b01000100, 0b01000100,
@ -1713,7 +1722,7 @@ static void drawCodeToolbar(Code* code)
enum {Count = sizeof Icons / BITS_IN_BYTE}; enum {Count = sizeof Icons / BITS_IN_BYTE};
enum {Size = 7}; 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++) for(s32 i = 0; i < Count; i++)
{ {
@ -1730,14 +1739,21 @@ static void drawCodeToolbar(Code* code)
if(checkMouseClick(&rect, SDL_BUTTON_LEFT)) 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); if(code->mode == mode) code->escape(code);
else setCodeMode(code, mode); else setCodeMode(code, mode);
} }
} }
}
bool active = i == code->mode - TEXT_FIND_MODE; bool active = i == code->mode - TEXT_EDIT_MODE && i != 0;
if(active) if(active)
code->tic->api.rect(code->tic, rect.x, rect.y, Size, Size, systemColor(tic_color_blue)); code->tic->api.rect(code->tic, rect.x, rect.y, Size, Size, systemColor(tic_color_blue));
@ -1756,6 +1772,7 @@ static void tick(Code* code)
switch(code->mode) switch(code->mode)
{ {
case TEXT_RUN_CODE: runProject(); break;
case TEXT_EDIT_MODE: textEditTick(code); break; case TEXT_EDIT_MODE: textEditTick(code); break;
case TEXT_FIND_MODE: textFindTick(code); break; case TEXT_FIND_MODE: textFindTick(code); break;
case TEXT_GOTO_MODE: textGoToTick(code); break; case TEXT_GOTO_MODE: textGoToTick(code); break;

View File

@ -72,6 +72,7 @@ struct Code
enum enum
{ {
TEXT_RUN_CODE,
TEXT_EDIT_MODE, TEXT_EDIT_MODE,
TEXT_FIND_MODE, TEXT_FIND_MODE,
TEXT_GOTO_MODE, TEXT_GOTO_MODE,

View File

@ -1363,7 +1363,7 @@ static void onFullscreen()
SDL_SetWindowFullscreen(studio.window, studio.fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0); SDL_SetWindowFullscreen(studio.window, studio.fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
} }
static void runProject() void runProject()
{ {
studio.tic->api.reset(studio.tic); studio.tic->api.reset(studio.tic);