<commit_before>--=========== Copyright © 2016, Planimeter, All rights reserved. =============--
--
-- Purpose:
--
--============================================================================--

local SDL = require( "lib.sdl" )
local ffi = require( "ffi" )

local framework      = framework
local collectgarbage = collectgarbage
local string         = string

module( "framework.event" )

function poll()
	event = event or SDL.SDL_Event()
	return SDL.SDL_PollEvent( event ) ~= 0 and event or nil
end

local function windowevent( window )
	if ( window.event == ffi.C.SDL_WINDOWEVENT_SHOWN ) then
		framework.visible( true )
	elseif ( window.event == ffi.C.SDL_WINDOWEVENT_HIDDEN ) then
		framework.visible( false )
	elseif ( window.event == ffi.C.SDL_WINDOWEVENT_MOVED ) then
		framework.move( window.data1, window.data2 )
	elseif ( window.event == ffi.C.SDL_WINDOWEVENT_RESIZED ) then
		framework.resize( window.data1, window.data2 )
	elseif ( window.event == ffi.C.SDL_WINDOWEVENT_SIZE_CHANGED ) then
		framework.window.resize( window.data1, window.data2 )
	elseif ( window.event == ffi.C.SDL_WINDOWEVENT_MINIMIZED ) then
		framework.minimize()
	elseif ( window.event == ffi.C.SDL_WINDOWEVENT_MAXIMIZED ) then
		framework.maximize()
	elseif ( window.event == ffi.C.SDL_WINDOWEVENT_RESTORED ) then
		framework.restore()
	elseif ( window.event == ffi.C.SDL_WINDOWEVENT_ENTER ) then
		framework.mousefocus( true )
	elseif ( window.event == ffi.C.SDL_WINDOWEVENT_LEAVE ) then
		framework.mousefocus( false )
	elseif ( window.event == ffi.C.SDL_WINDOWEVENT_FOCUS_GAINED ) then
		framework.focus( true )
	elseif ( window.event == ffi.C.SDL_WINDOWEVENT_FOCUS_LOST ) then
		framework.focus( false )
	end
end

function handle( e )
	if ( e.type == ffi.C.SDL_APP_LOWMEMORY ) then
		framework.lowmemory()
		collectgarbage()
		collectgarbage()
	elseif ( e.type == ffi.C.SDL_WINDOWEVENT ) then
		windowevent( e.window )
	elseif ( e.type == ffi.C.SDL_KEYDOWN ) then
		local key      = SDL.SDL_GetKeyName( e.key.keysym.sym )
		key            = ffi.string( key )
		key            = string.lower( key )
		local scancode = SDL.SDL_GetScancodeName( e.key.keysym.scancode )
		scancode       = ffi.string( scancode )
		scancode       = string.lower( scancode )
		local isrepeat = e.key[ "repeat" ] == 1 and true or false
		framework.keypressed( key, scancode, isrepeat )
	elseif ( e.type == ffi.C.SDL_KEYUP ) then
		local key      = SDL.SDL_GetKeyName( e.key.keysym.sym )
		key            = ffi.string( key )
		key            = string.lower( key )
		local scancode = SDL.SDL_GetScancodeName( e.key.keysym.scancode )
		scancode       = ffi.string( scancode )
		scancode       = string.lower( scancode )
		framework.keyreleased( key, scancode )
	end
end<commit_msg>Stub event support<commit_after>--=========== Copyright © 2016, Planimeter, All rights reserved. =============--
--
-- Purpose:
--
--============================================================================--

local SDL = require( "lib.sdl" )
local ffi = require( "ffi" )

local framework      = framework
local collectgarbage = collectgarbage
local string         = string

module( "framework.event" )

function poll()
	event = event or SDL.SDL_Event()
	return SDL.SDL_PollEvent( event ) ~= 0 and event or nil
end

local function windowevent( window )
	if ( window.event == ffi.C.SDL_WINDOWEVENT_SHOWN ) then
		framework.visible( true )
	elseif ( window.event == ffi.C.SDL_WINDOWEVENT_HIDDEN ) then
		framework.visible( false )
	elseif ( window.event == ffi.C.SDL_WINDOWEVENT_MOVED ) then
		framework.move( window.data1, window.data2 )
	elseif ( window.event == ffi.C.SDL_WINDOWEVENT_RESIZED ) then
		framework.resize( window.data1, window.data2 )
	elseif ( window.event == ffi.C.SDL_WINDOWEVENT_SIZE_CHANGED ) then
		framework.window.resize( window.data1, window.data2 )
	elseif ( window.event == ffi.C.SDL_WINDOWEVENT_MINIMIZED ) then
		framework.minimize()
	elseif ( window.event == ffi.C.SDL_WINDOWEVENT_MAXIMIZED ) then
		framework.maximize()
	elseif ( window.event == ffi.C.SDL_WINDOWEVENT_RESTORED ) then
		framework.restore()
	elseif ( window.event == ffi.C.SDL_WINDOWEVENT_ENTER ) then
		framework.mousefocus( true )
	elseif ( window.event == ffi.C.SDL_WINDOWEVENT_LEAVE ) then
		framework.mousefocus( false )
	elseif ( window.event == ffi.C.SDL_WINDOWEVENT_FOCUS_GAINED ) then
		framework.focus( true )
	elseif ( window.event == ffi.C.SDL_WINDOWEVENT_FOCUS_LOST ) then
		framework.focus( false )
	end
end

function handle( e )
	if ( e.type == ffi.C.SDL_APP_LOWMEMORY ) then
		framework.lowmemory()
		collectgarbage()
		collectgarbage()
	elseif ( e.type == ffi.C.SDL_WINDOWEVENT ) then
		windowevent( e.window )
	elseif ( e.type == ffi.C.SDL_KEYDOWN ) then
		local key      = SDL.SDL_GetKeyName( e.key.keysym.sym )
		key            = ffi.string( key )
		key            = string.lower( key )
		local scancode = SDL.SDL_GetScancodeName( e.key.keysym.scancode )
		scancode       = ffi.string( scancode )
		scancode       = string.lower( scancode )
		local isrepeat = e.key[ "repeat" ] == 1 and true or false
		framework.keypressed( key, scancode, isrepeat )
	elseif ( e.type == ffi.C.SDL_KEYUP ) then
		local key      = SDL.SDL_GetKeyName( e.key.keysym.sym )
		key            = ffi.string( key )
		key            = string.lower( key )
		local scancode = SDL.SDL_GetScancodeName( e.key.keysym.scancode )
		scancode       = ffi.string( scancode )
		scancode       = string.lower( scancode )
		framework.keyreleased( key, scancode )
	elseif ( e.type == ffi.C.SDL_TEXTEDITING ) then
	elseif ( e.type == ffi.C.SDL_TEXTINPUT ) then
	elseif ( e.type == ffi.C.SDL_MOUSEMOTION ) then
	elseif ( e.type == ffi.C.SDL_MOUSEBUTTONDOWN ) then
	elseif ( e.type == ffi.C.SDL_MOUSEBUTTONUP ) then
	elseif ( e.type == ffi.C.SDL_MOUSEWHEEL ) then
	elseif ( e.type == ffi.C.SDL_JOYAXISMOTION ) then
	elseif ( e.type == ffi.C.SDL_JOYBALLMOTION ) then
	elseif ( e.type == ffi.C.SDL_JOYHATMOTION ) then
	elseif ( e.type == ffi.C.SDL_JOYBUTTONDOWN ) then
	elseif ( e.type == ffi.C.SDL_JOYBUTTONUP ) then
	elseif ( e.type == ffi.C.SDL_JOYDEVICEADDED ) then
	elseif ( e.type == ffi.C.SDL_JOYDEVICEREMOVED ) then
	elseif ( e.type == ffi.C.SDL_CONTROLLERAXISMOTION ) then
	elseif ( e.type == ffi.C.SDL_CONTROLLERBUTTONDOWN ) then
	elseif ( e.type == ffi.C.SDL_CONTROLLERBUTTONUP ) then
	elseif ( e.type == ffi.C.SDL_CONTROLLERDEVICEADDED ) then
	elseif ( e.type == ffi.C.SDL_CONTROLLERDEVICEREMOVED ) then
	elseif ( e.type == ffi.C.SDL_CONTROLLERDEVICEREMAPPED ) then
	elseif ( e.type == ffi.C.SDL_FINGERDOWN ) then
	elseif ( e.type == ffi.C.SDL_FINGERUP ) then
	elseif ( e.type == ffi.C.SDL_FINGERMOTION ) then
	elseif ( e.type == ffi.C.SDL_DOLLARGESTURE ) then
	elseif ( e.type == ffi.C.SDL_DOLLARRECORD ) then
	elseif ( e.type == ffi.C.SDL_MULTIGESTURE ) then
	elseif ( e.type == ffi.C.SDL_CLIPBOARDUPDATE ) then
	elseif ( e.type == ffi.C.SDL_DROPFILE ) then
	elseif ( e.type == ffi.C.SDL_DROPTEXT ) then
	elseif ( e.type == ffi.C.SDL_DROPBEGIN ) then
	elseif ( e.type == ffi.C.SDL_DROPCOMPLETE ) then
	elseif ( e.type == ffi.C.SDL_AUDIODEVICEADDED ) then
	elseif ( e.type == ffi.C.SDL_AUDIODEVICEREMOVED ) then
	elseif ( e.type == ffi.C.SDL_RENDER_TARGETS_RESET ) then
	elseif ( e.type == ffi.C.SDL_RENDER_DEVICE_RESET ) then
	end
end
{'fraction_non_alphanumeric': 0.14321123657394658, 'fraction_numerical': 0.0033048746901679976, 'mean_word_length': 3.5997466751108296, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6771789', 'n_tokens_mistral': 2867, 'n_tokens_neox': 2721, 'n_words': 543}