101 lines
3.4 KiB
C
101 lines
3.4 KiB
C
// lite {
|
|
#define f_gc f_gc2
|
|
#define clip clip2
|
|
#define GLEQ_IMPLEMENTATION
|
|
#include "3rd_lite_sys_gleq.h"
|
|
#include "3rd_lite_sys.h"
|
|
#include "3rd_lite.h"
|
|
// }
|
|
|
|
TODO("new: integrate with Art/ browser")
|
|
TODO("bug: lite key bindings are being sent to editor")
|
|
TODO("bug: not sending quit signal to lite neither at window close nor editor close (see: temporary files)")
|
|
TODO("bug: missing search results window")
|
|
TODO("bug: missing code completions popup")
|
|
// TODO("eval: https://github.com/drmargarido/linters")
|
|
// TODO("eval: https://github.com/monolifed/theme16")
|
|
// TODO("eval: https://github.com/vincens2005/lite-formatters")
|
|
// https://github.com/takase1121/lite-xl-img
|
|
// https://github.com/takase1121/lite-xl-finder
|
|
// https://github.com/rxi/lite/commit/236a585756cb9fa70130eee6c9a604780aced424 > suru.png
|
|
// https://github.com/rxi/lite/commit/f90b00748e1fe1cd2340aaa06d2526a1b2ea54ec
|
|
|
|
int ui_texture_fit(texture_t t, struct nk_rect bounds) {
|
|
// allocate complete window space
|
|
struct nk_rect total_space = nk_window_get_content_region(ui_ctx);
|
|
nk_layout_space_begin(ui_ctx, NK_DYNAMIC, total_space.h - 4, 1); // -4 to hide scrollbar Y
|
|
nk_layout_space_push(ui_ctx, nk_rect(0,0,1,1));
|
|
|
|
struct nk_command_buffer *canvas = nk_window_get_canvas(ui_ctx);
|
|
struct nk_image image = nk_image_id((int)t.id);
|
|
nk_draw_image(canvas, bounds, &image, nk_white);
|
|
|
|
nk_layout_space_end(ui_ctx);
|
|
return 0;
|
|
}
|
|
|
|
#define LITE_ICON ICON_MDI_SCRIPT_TEXT
|
|
#define LITE_TITLE "Script " LITE_ICON
|
|
|
|
EDITOR_BIND(script, "held(CTRL)&down(6)", { ui_show(LITE_TITLE, ui_visible(LITE_TITLE) ^ true); });
|
|
|
|
int editor_scripted(int window_mode) {
|
|
window_mode = EDITOR_WINDOW; // force mode
|
|
|
|
static lua_State *L = 0;
|
|
do_once {
|
|
L = script_init_env(SCRIPT_LUA|SCRIPT_DEBUGGER);
|
|
|
|
const char *platform = "" // "Android" "FreeBSD" "OpenBSD" "NetBSD"
|
|
ifdef(ems, "Emscripten")
|
|
ifdef(linux, "Linux")
|
|
ifdef(osx, "macOS")
|
|
ifdef(win32, "Windows")
|
|
;
|
|
const char *pathexe = vac("%s%s%s", app_path(), app_name(), ifdef(win32, ".exe", ""));
|
|
|
|
gleqInit();
|
|
gleqTrackWindow(window_handle());
|
|
lt_init(L, window_handle(), LT_DATAPATH, __argc, __argv, window_scale(), platform, pathexe);
|
|
}
|
|
|
|
unsigned lt_none = 0u;
|
|
unsigned lt_all = ~0u & ~(GLEQ_WINDOW_MOVED/*|GLEQ_WINDOW_RESIZED|GLEQ_WINDOW_REFRESH*/);
|
|
lt_events = lt_none;
|
|
|
|
int mouse_in_rect = 0;
|
|
if( editor_begin(LITE_TITLE, window_mode) ) {
|
|
|
|
lt_events = lt_all;
|
|
if( !nk_window_has_focus(ui_ctx) ) lt_events = lt_none;
|
|
|
|
struct nk_rect bounds = nk_window_get_content_region(ui_ctx);
|
|
|
|
lt_mx = input(MOUSE_X) - bounds.x;
|
|
lt_my = input(MOUSE_Y) - bounds.y;
|
|
lt_wx = bounds.x;
|
|
lt_wy = bounds.y;
|
|
lt_ww = bounds.w;
|
|
lt_wh = bounds.h;
|
|
|
|
if( lt_resizesurface(lt_getsurface(0), lt_ww, lt_wh) ) {
|
|
gleq_window_refresh_callback(window_handle());
|
|
}
|
|
// fullscreen_quad_rgb( lt_getsurface(0)->t, 1.2f );
|
|
ui_texture_fit(lt_getsurface(0)->t, bounds);
|
|
|
|
if( !!nk_input_is_mouse_hovering_rect(&ui_ctx->input, ((struct nk_rect){lt_wx+5,lt_wy+5,lt_ww-10,lt_wh-10})) ) {
|
|
lt_events &= ~(1<<31); // dont cursor shape
|
|
}
|
|
|
|
editor_end(window_mode);
|
|
}
|
|
|
|
lt_tick(L);
|
|
return 0;
|
|
}
|
|
|
|
AUTORUN {
|
|
array_push(editor.subeditors, editor_scripted);
|
|
}
|