diff --git a/ascii.cpp b/ascii.cpp index fcbdadf..bf1064a 100644 --- a/ascii.cpp +++ b/ascii.cpp @@ -273,7 +273,7 @@ int main(int argc,char*argv[]) { load(dropped_filedir); } if (mini_eve.type == SDL_EVENT_KEY_DOWN) { - if (mini_eve.key.scancode == SDL_SCANCODE_ESCAPE) { + if ((mini_eve.key.scancode == SDL_SCANCODE_ESCAPE) && (mini_eve.key.mod & SDL_KMOD_LCTRL) ) { if (lua_is_playing()) { lua_pause(); //lua_quit(); @@ -393,6 +393,10 @@ int main(int argc,char*argv[]) { return 0; } +void wintitle(const char* title) { + SDL_SetWindowTitle(mini_win, title); +} + void cls(uint8_t value) { SDL_memset(char_screen, value, screen_width*screen_height); if (current_mode != 0) SDL_memset(color_screen, current_color, screen_width*screen_height); @@ -561,8 +565,8 @@ void debugchr(const uint8_t chr) { int pos = cursor_x+cursor_y*screen_width; if (chr == 8) { if (cursor_x>1) { - char_screen[pos++] = 32; - char_screen[pos] = 32; + char_screen[pos] = ' '; + char_screen[pos-1] = ' '; cursor_x--; } else { play("c"); diff --git a/ascii.h b/ascii.h index 320a0f8..ea2880f 100644 --- a/ascii.h +++ b/ascii.h @@ -132,6 +132,7 @@ void execute_run(); const char* get_filename(); +void wintitle(const char *title); void cls(uint8_t value=32); void ink(uint8_t value); // global::ink void paper(uint8_t value); // global::paper diff --git a/lua.cpp b/lua.cpp index 2165ad2..cc67e8a 100644 --- a/lua.cpp +++ b/lua.cpp @@ -87,6 +87,12 @@ void table_to_str(lua_State *L, int indx) { extern "C" { + static int cpp_wintitle(lua_State *L) { + const char *text = luaL_checkstring(L, 1); + wintitle(text); + return 0; + } + static int cpp_cls(lua_State *L) { uint8_t color = luaL_optinteger(L, 1, 32); cls(color); @@ -431,7 +437,7 @@ const char boot[] = "ink(1) print('G A M E',8,16)" "ink(4) print('S Y S T E M',20,16)" "ink(7) print('mini',9,8)" - "ink(8) print('v0.7.7',34,29)" + "ink(8) print('v0.7.8',34,29)" "w=time() " "end " "function update()" @@ -467,6 +473,7 @@ void lua_init(const char* filename, const bool start_playing) { } } + lua_pushcfunction(L,cpp_wintitle); lua_setglobal(L, "wintitle"); lua_pushcfunction(L,cpp_cls); lua_setglobal(L, "cls"); lua_pushcfunction(L,cpp_ink); lua_setglobal(L, "ink"); lua_pushcfunction(L,cpp_paper); lua_setglobal(L, "paper"); @@ -670,6 +677,8 @@ void lua_init(const char* filename, const bool start_playing) { lua_state = start_playing ? STATE_PLAYING : STATE_PAUSED; } +#include + void lua_call_cmd(const char* str) { if (str[0]=='?') { const int size = strlen(str)+14; @@ -685,9 +694,12 @@ void lua_call_cmd(const char* str) { } } else { if (luaL_dostring(L, str)) { - debug("ERROR:",false); - debug(lua_tostring(L, -1)); - lua_pop(L,1); + std::string cmd = std::string(str) + std::string("()"); + if (luaL_dostring(L, cmd.c_str())) { + debug("ERROR:",false); + debug(lua_tostring(L, -1)); + lua_pop(L,1); + } } } }