https://bitbucket.org/daniel_fort/magic-lantern
Raw File
Tip revision: e6ebf3ba6f9fc510667e6ee2e3c4c63b72736ceb authored by Daniel Fort on 24 December 2016, 01:31:19 UTC
Closed branch raw_video_10bit_12bit_debug
Tip revision: e6ebf3b
lua_console.c
/***
 Functions for writing data to the console
 
 @author Magic Lantern Team
 @copyright 2014
 @license GPL
 @module console
 */

#include <dryos.h>
#include <string.h>
#include <console.h>
#include "lua_common.h"

/***
 Show the console
 @function show
 */
static int luaCB_console_show(lua_State * L)
{
    console_show();
    return 0;
}

/***
 Hide the console
 @function hide
 */
static int luaCB_console_hide(lua_State * L)
{
    console_hide();
    return 0;
}

/***
 Clear the console contents
 @function clear
 */
static int luaCB_console_clear(lua_State * L)
{
    console_clear();
    return 0;
}

/***
 Write some text to the console
 @tparam string text the text to write
 @function write
 */
static int luaCB_console_write(lua_State * L)
{
    if(lua_isstring(L, 1)) printf("%s",lua_tostring(L, 1));
    return 0;
}

static int luaCB_console_index(lua_State * L) { lua_rawget(L, 1); return 1; }
static int luaCB_console_newindex(lua_State * L) { lua_rawset(L, 1); return 0; }


static const char * lua_console_fields[] =
{
    NULL
};

static const luaL_Reg consolelib[] =
{
    { "show", luaCB_console_show },
    { "hide", luaCB_console_hide },
    { "clear", luaCB_console_clear },
    { "write", luaCB_console_write },
    { NULL, NULL }
};

LUA_LIB(console)
back to top