@ -94,7 +94,7 @@ top:
return 2 ;
return 2 ;
case SDL_MOUSEBUTTONDOWN :
case SDL_MOUSEBUTTONDOWN :
if ( e . button . button = = 1 )
if ( e . button . button = = 1 )
SDL_CaptureMouse ( 1 ) ;
SDL_CaptureMouse ( 1 ) ;
lua_pushstring ( L , " mousepressed " ) ;
lua_pushstring ( L , " mousepressed " ) ;
lua_pushstring ( L , button_name ( e . button . button ) ) ;
lua_pushstring ( L , button_name ( e . button . button ) ) ;
@ -104,7 +104,7 @@ top:
return 5 ;
return 5 ;
case SDL_MOUSEBUTTONUP :
case SDL_MOUSEBUTTONUP :
if ( e . button . button = = 1 )
if ( e . button . button = = 1 )
SDL_CaptureMouse ( 0 ) ;
SDL_CaptureMouse ( 0 ) ;
lua_pushstring ( L , " mousereleased " ) ;
lua_pushstring ( L , " mousereleased " ) ;
lua_pushstring ( L , button_name ( e . button . button ) ) ;
lua_pushstring ( L , button_name ( e . button . button ) ) ;
@ -123,7 +123,8 @@ top:
case SDL_MOUSEWHEEL :
case SDL_MOUSEWHEEL :
lua_pushstring ( L , " mousewheel " ) ;
lua_pushstring ( L , " mousewheel " ) ;
lua_pushnumber ( L , e . wheel . y ) ;
lua_pushnumber ( L , e . wheel . y ) ;
return 2 ;
lua_pushnumber ( L , e . wheel . x ) ;
return 3 ;
default :
default :
goto top ;
goto top ;
@ -189,7 +190,7 @@ static int f_set_window_mode(lua_State *L)
n = = WIN_FULLSCREEN ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0 ) ;
n = = WIN_FULLSCREEN ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0 ) ;
if ( n = = WIN_NORMAL )
if ( n = = WIN_NORMAL )
SDL_RestoreWindow ( window ) ;
SDL_RestoreWindow ( window ) ;
if ( n = = WIN_MAXIMIZED )
if ( n = = WIN_MAXIMIZED )
SDL_MaximizeWindow ( window ) ;
SDL_MaximizeWindow ( window ) ;
return 0 ;
return 0 ;
}
}
@ -226,7 +227,7 @@ static int f_chdir(lua_State *L)
{
{
const char * path = luaL_checkstring ( L , 1 ) ;
const char * path = luaL_checkstring ( L , 1 ) ;
int err = chdir ( path ) ;
int err = chdir ( path ) ;
if ( err )
if ( err )
luaL_error ( L , " chdir() failed " ) ;
luaL_error ( L , " chdir() failed " ) ;
return 0 ;
return 0 ;
}
}
@ -247,9 +248,9 @@ static int f_list_dir(lua_State *L)
int i = 1 ;
int i = 1 ;
struct dirent * entry ;
struct dirent * entry ;
while ( ( entry = readdir ( dir ) ) ) {
while ( ( entry = readdir ( dir ) ) ) {
if ( strcmp ( entry - > d_name , " . " ) = = 0 )
if ( strcmp ( entry - > d_name , " . " ) = = 0 )
continue ;
continue ;
if ( strcmp ( entry - > d_name , " .. " ) = = 0 )
if ( strcmp ( entry - > d_name , " .. " ) = = 0 )
continue ;
continue ;
lua_pushstring ( L , entry - > d_name ) ;
lua_pushstring ( L , entry - > d_name ) ;
lua_rawseti ( L , - 2 , i ) ;
lua_rawseti ( L , - 2 , i ) ;
@ -264,7 +265,7 @@ static int f_absolute_path(lua_State *L)
{
{
const char * path = luaL_checkstring ( L , 1 ) ;
const char * path = luaL_checkstring ( L , 1 ) ;
char * res = realpath ( path , NULL ) ;
char * res = realpath ( path , NULL ) ;
if ( ! res )
if ( ! res )
return 0 ;
return 0 ;
lua_pushstring ( L , res ) ;
lua_pushstring ( L , res ) ;
free ( res ) ;
free ( res ) ;
@ -339,7 +340,7 @@ static int f_exec(lua_State *L)
size_t len ;
size_t len ;
const char * cmd = luaL_checklstring ( L , 1 , & len ) ;
const char * cmd = luaL_checklstring ( L , 1 , & len ) ;
char * buf = malloc ( len + 32 ) ;
char * buf = malloc ( len + 32 ) ;
if ( ! buf )
if ( ! buf )
luaL_error ( L , " buffer allocation failed " ) ;
luaL_error ( L , " buffer allocation failed " ) ;
sprintf ( buf , " %s & " , cmd ) ;
sprintf ( buf , " %s & " , cmd ) ;
int res = system ( buf ) ;
int res = system ( buf ) ;
@ -357,7 +358,7 @@ static int f_fuzzy_match(lua_State *L)
int run = 0 ;
int run = 0 ;
while ( * str & & * ptn ) {
while ( * str & & * ptn ) {
while ( * str = = ' ' )
while ( * str = = ' ' )
str + + ;
str + + ;
while ( * ptn = = ' ' )
while ( * ptn = = ' ' )
ptn + + ;
ptn + + ;
@ -371,7 +372,7 @@ static int f_fuzzy_match(lua_State *L)
}
}
str + + ;
str + + ;
}
}
if ( * ptn )
if ( * ptn )
return 0 ;
return 0 ;
lua_pushnumber ( L , score - ( int ) strlen ( str ) ) ;
lua_pushnumber ( L , score - ( int ) strlen ( str ) ) ;