#include "ebisp/scope.h"
#include "ebisp/std.h"
#include "game/level.h"
-#include "game/level/player/rigid_rect.h"
-#include "game/level_script.h"
#include "sdl/renderer.h"
#include "system/log.h"
#include "system/log_script.h"
{
Lt *lt = create_lt();
- if (lt == NULL) {
- return NULL;
- }
- Console *console = PUSH_LT(lt, nth_alloc(sizeof(Console)), free);
+ Console *console = PUSH_LT(lt, nth_calloc(1, sizeof(Console)), free);
if (console == NULL) {
RETURN_LT(lt, NULL);
}
load_std_library(console->gc, &console->scope);
load_log_library(console->gc, &console->scope);
+ /* TODO(#669): how to report EvalResult error from create_console? */
broadcast_load_library(broadcast, console->gc, &console->scope);
console->edit_field = PUSH_LT(
lt,
create_edit_field(
- font,
vec(FONT_WIDTH_SCALE, FONT_HEIGHT_SCALE),
CONSOLE_FOREGROUND),
destroy_edit_field);
console->eval_result = PUSH_LT(
lt,
- nth_alloc(sizeof(char) * CONSOLE_EVAL_RESULT_SIZE),
+ nth_calloc(1, sizeof(char) * CONSOLE_EVAL_RESULT_SIZE),
free);
if (console->eval_result == NULL) {
RETURN_LT(lt, NULL);
const SDL_Event *event)
{
switch(event->type) {
- case SDL_KEYDOWN:
+ case SDL_KEYDOWN: {
switch(event->key.keysym.sym) {
case SDLK_RETURN:
return console_eval_input(console);
history_next(console->history);
return 0;
}
- break;
+
+ return edit_field_keyboard(console->edit_field, &event->key);
+ } break;
+
+ case SDL_TEXTINPUT:
+ return edit_field_text_input(console->edit_field, &event->text);
+
+ default: {}
}
- return edit_field_handle_event(console->edit_field, event);
+ return 0;
}
int console_render(const Console *console,
+ Camera *camera,
SDL_Renderer *renderer)
{
/* TODO(#364): console doesn't have any padding around the edit fields */
}
if (edit_field_render(console->edit_field,
- renderer,
+ camera,
vec(0.0f, y + CONSOLE_LOG_HEIGHT)) < 0) {
return -1;
}