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