Compare commits
2 Commits
2d79790d83
...
85ca1a6a9e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
85ca1a6a9e | ||
|
|
5a12ab8d8c |
81
build.sh
Normal file → Executable file
81
build.sh
Normal file → Executable file
@@ -3,79 +3,10 @@
|
|||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
|
|
||||||
if [ "$1" = "release" ]; then
|
FLAGS="-nostdlib++ -fno-exceptions -fdiagnostics-absolute-paths -g -Wno-writable-strings -I../src -DDEBUG_BUILD=1"
|
||||||
profile_flags="-DDEBUG_BUILD=0 -O2"
|
# clang -o metaprogram $FLAGS ../src/metaprogram/metaprogram.cpp
|
||||||
else
|
# ./metaprogram
|
||||||
profile_flags="-DDEBUG_BUILD=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -f "lbaselib.o" ]; then
|
I="-I../src/external/SDL/include -I../src/external/lua/src -I../src/external/glad"
|
||||||
clang -g -I../src/external/lua/src -I../src/external/glad \
|
clang -o te $FLAGS ../src/text_editor/text_editor.cpp $I -lSDL3 -lm -lbacktrace
|
||||||
../src/external/lua/src/lbaselib.c \
|
cp te ../data/te
|
||||||
../src/external/lua/src/lctype.c \
|
|
||||||
../src/external/lua/src/ldo.c \
|
|
||||||
../src/external/lua/src/lgc.c \
|
|
||||||
../src/external/lua/src/liolib.c \
|
|
||||||
../src/external/lua/src/lmem.c \
|
|
||||||
../src/external/lua/src/lopcodes.c \
|
|
||||||
../src/external/lua/src/lstate.c \
|
|
||||||
../src/external/lua/src/ltable.c \
|
|
||||||
../src/external/lua/src/lundump.c \
|
|
||||||
../src/external/lua/src/lzio.c \
|
|
||||||
../src/external/lua/src/lapi.c \
|
|
||||||
../src/external/lua/src/lcode.c \
|
|
||||||
../src/external/lua/src/ldblib.c \
|
|
||||||
../src/external/lua/src/ldump.c \
|
|
||||||
../src/external/lua/src/llex.c \
|
|
||||||
../src/external/lua/src/loadlib.c \
|
|
||||||
../src/external/lua/src/loslib.c \
|
|
||||||
../src/external/lua/src/lstring.c \
|
|
||||||
../src/external/lua/src/ltablib.c \
|
|
||||||
../src/external/lua/src/lutf8lib.c \
|
|
||||||
../src/external/lua/src/lauxlib.c \
|
|
||||||
../src/external/lua/src/lcorolib.c \
|
|
||||||
../src/external/lua/src/ldebug.c \
|
|
||||||
../src/external/lua/src/lfunc.c \
|
|
||||||
../src/external/lua/src/linit.c \
|
|
||||||
../src/external/lua/src/lmathlib.c \
|
|
||||||
../src/external/lua/src/lobject.c \
|
|
||||||
../src/external/lua/src/lparser.c \
|
|
||||||
../src/external/lua/src/lstrlib.c \
|
|
||||||
../src/external/lua/src/ltm.c \
|
|
||||||
../src/external/lua/src/lvm.c \
|
|
||||||
../src/external/glad/glad.c \
|
|
||||||
-c
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -f "metaprogram.exe" ]; then
|
|
||||||
clang ../src/metaprogram/metaprogram.cpp ../src/basic/unix.cpp -o metaprogram.exe \
|
|
||||||
-nostdlib++ -fno-exceptions -fdiagnostics-absolute-paths -g \
|
|
||||||
-Wno-writable-strings \
|
|
||||||
-I../src
|
|
||||||
fi
|
|
||||||
./metaprogram.exe
|
|
||||||
|
|
||||||
clang ../src/text_editor/text_editor.cpp ../src/basic/unix.cpp -o te_linux.exe \
|
|
||||||
-nostdlib++ -fno-exceptions -fdiagnostics-absolute-paths -g \
|
|
||||||
$profile_flags \
|
|
||||||
-Wno-writable-strings \
|
|
||||||
-I../src/external/SDL/include \
|
|
||||||
-I../src/external/lua/src \
|
|
||||||
-I../src/external/glad \
|
|
||||||
-I../src/ \
|
|
||||||
-lm \
|
|
||||||
../src/external/SDL/build/libSDL3.a \
|
|
||||||
lbaselib.o lctype.o ldo.o lgc.o liolib.o lmem.o \
|
|
||||||
lopcodes.o lstate.o ltable.o lundump.o lzio.o lapi.o lcode.o ldblib.o ldump.o \
|
|
||||||
llex.o loadlib.o loslib.o lstring.o ltablib.o lutf8lib.o lauxlib.o lcorolib.o ldebug.o \
|
|
||||||
lfunc.o linit.o lmathlib.o lobject.o lparser.o lstrlib.o ltm.o lvm.o \
|
|
||||||
glad.o \
|
|
||||||
|
|
||||||
|
|
||||||
if [ "$1" = "release" ]; then
|
|
||||||
cp te_linux.exe ../data/te
|
|
||||||
echo written ../data/te
|
|
||||||
else
|
|
||||||
cp te_linux.exe ../data/te_debug
|
|
||||||
echo written ../data/te_debug
|
|
||||||
fi
|
|
||||||
0
build_web.bat
Normal file → Executable file
0
build_web.bat
Normal file → Executable file
0
build_web.sh
Normal file → Executable file
0
build_web.sh
Normal file → Executable file
@@ -26,11 +26,6 @@ Splits:
|
|||||||
- move titlebar, search to splits?
|
- move titlebar, search to splits?
|
||||||
|
|
||||||
|
|
||||||
Linux
|
|
||||||
- Add backtrace
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Commands TODO:
|
Commands TODO:
|
||||||
- Search
|
- Search
|
||||||
- Ctrl + F
|
- Ctrl + F
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ API bool VDecommit(void *p, size_t size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#elif OS_LINUX || OS_MAC
|
#elif OS_LINUX || OS_MAC
|
||||||
|
#include <sys/mman.h>
|
||||||
|
|
||||||
|
|
||||||
API void *VReserve(size_t size) {
|
API void *VReserve(size_t size) {
|
||||||
void *result = mmap(0, size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, (off_t)0);
|
void *result = mmap(0, size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, (off_t)0);
|
||||||
|
|||||||
@@ -14,11 +14,58 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <spawn.h>
|
#include <spawn.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
#include <execinfo.h>
|
||||||
|
#include <backtrace.h>
|
||||||
|
|
||||||
API void (*Error)(const char *, ...);
|
API void (*Error)(const char *, ...);
|
||||||
|
|
||||||
|
struct backtrace_state *backtrace_state = NULL;
|
||||||
|
|
||||||
|
void os_core_backtrace_error_callback(void *data, const char *msg, int errnum) {
|
||||||
|
Error("libbacktrace error: %s (errnum: %d)\n", msg, errnum);
|
||||||
|
}
|
||||||
|
|
||||||
|
int os_core_backtrace_print_callback(void *data, uintptr_t pc, const char *filename, int lineno, const char *function) {
|
||||||
|
bool printed = false;
|
||||||
|
if (filename != NULL) {
|
||||||
|
char buffer[512];
|
||||||
|
char *f = realpath(filename, buffer);
|
||||||
|
printf("%s:%d:1: ", f, lineno);
|
||||||
|
printed = true;
|
||||||
|
}
|
||||||
|
if (function != NULL) {
|
||||||
|
printf("%s", function);
|
||||||
|
printed = true;
|
||||||
|
}
|
||||||
|
if (printed) {
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void os_unix_crash_handler(int signal, siginfo_t* info, void* context) {
|
||||||
|
backtrace_full(backtrace_state, 2, os_core_backtrace_print_callback, os_core_backtrace_error_callback, NULL);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void os_unix_register_crash_handler(void) {
|
||||||
|
backtrace_state = backtrace_create_state(NULL, 1, os_core_backtrace_error_callback, NULL);
|
||||||
|
|
||||||
|
struct sigaction sa;
|
||||||
|
sa.sa_sigaction = os_unix_crash_handler;
|
||||||
|
sigemptyset(&sa.sa_mask);
|
||||||
|
sa.sa_flags = SA_RESTART | SA_SIGINFO;
|
||||||
|
|
||||||
|
sigaction(SIGSEGV, &sa, NULL);
|
||||||
|
sigaction(SIGABRT, &sa, NULL);
|
||||||
|
sigaction(SIGBUS, &sa, NULL);
|
||||||
|
sigaction(SIGILL, &sa, NULL);
|
||||||
|
sigaction(SIGFPE, &sa, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
API void InitOS(void (*error_proc)(const char *, ...)) {
|
API void InitOS(void (*error_proc)(const char *, ...)) {
|
||||||
Error = error_proc;
|
Error = error_proc;
|
||||||
|
os_unix_register_crash_handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
API String ReadFile(Allocator al, String path) {
|
API String ReadFile(Allocator al, String path) {
|
||||||
@@ -171,9 +218,9 @@ API void Advance(FileIter *it) {
|
|||||||
|
|
||||||
const char *dir_char_ending = it->is_directory ? "/" : "";
|
const char *dir_char_ending = it->is_directory ? "/" : "";
|
||||||
const char *separator = it->path.data[it->path.len - 1] == '/' ? "" : "/";
|
const char *separator = it->path.data[it->path.len - 1] == '/' ? "" : "/";
|
||||||
it->relative_path = Format(it->allocator, "%.*s%s%s%s", FmtString(it->path), separator, file->d_name, dir_char_ending);
|
it->relative_path = Format(it->allocator, "%S%s%s%s", it->path, separator, file->d_name, dir_char_ending);
|
||||||
it->absolute_path = GetAbsolutePath(it->allocator, it->relative_path);
|
it->absolute_path = GetAbsolutePath(it->allocator, it->relative_path);
|
||||||
if (it->is_directory) it->absolute_path = Format(it->allocator, "%.*s/", FmtString(it->absolute_path));
|
if (it->is_directory) it->absolute_path = Format(it->allocator, "%S/", it->absolute_path);
|
||||||
it->is_valid = true;
|
it->is_valid = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1467,13 +1467,11 @@ void InitBuffers() {
|
|||||||
Buffer *null_buffer = CreateBuffer(sys_allocator, GetUniqueBufferName(GetWorkingDir(scratch), "console"));
|
Buffer *null_buffer = CreateBuffer(sys_allocator, GetUniqueBufferName(GetWorkingDir(scratch), "console"));
|
||||||
View *null_view = CreateView(null_buffer->id);
|
View *null_view = CreateView(null_buffer->id);
|
||||||
Assert(null_buffer->id == NullBufferID && null_view->id == NullViewID);
|
Assert(null_buffer->id == NullBufferID && null_view->id == NullViewID);
|
||||||
|
|
||||||
TraceBuffer = CreateBuffer(sys_allocator, GetUniqueBufferName(WorkDir, "trace"));
|
TraceBuffer = CreateBuffer(sys_allocator, GetUniqueBufferName(WorkDir, "trace"));
|
||||||
TraceView = CreateView(TraceBuffer->id);
|
TraceView = CreateView(TraceBuffer->id);
|
||||||
GCInfoBuffer = CreateBuffer(sys_allocator, GetUniqueBufferName(WorkDir, "gc"));
|
GCInfoBuffer = CreateBuffer(sys_allocator, GetUniqueBufferName(WorkDir, "gc"));
|
||||||
EventBuffer = CreateBuffer(sys_allocator, GetUniqueBufferName(WorkDir, "events"));
|
EventBuffer = CreateBuffer(sys_allocator, GetUniqueBufferName(WorkDir, "events"));
|
||||||
ScratchBuffer = BufferOpenFile(GetUniqueBufferName(WorkDir, "scratch"));
|
ScratchBuffer = BufferOpenFile(GetUniqueBufferName(WorkDir, "scratch"));
|
||||||
|
|
||||||
EventBuffer->no_history = true;
|
EventBuffer->no_history = true;
|
||||||
GCInfoBuffer->no_history = true;
|
GCInfoBuffer->no_history = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -705,7 +705,7 @@ void SaveBuffer(Buffer *buffer) {
|
|||||||
void Command_Save() {
|
void Command_Save() {
|
||||||
BSet active = GetBSet(LastActiveLayoutWindowID);
|
BSet active = GetBSet(LastActiveLayoutWindowID);
|
||||||
SaveBuffer(active.buffer);
|
SaveBuffer(active.buffer);
|
||||||
}
|
} RegisterCommand(Command_Save);
|
||||||
|
|
||||||
int Lua_Save(lua_State *L) {
|
int Lua_Save(lua_State *L) {
|
||||||
Command_Save();
|
Command_Save();
|
||||||
@@ -718,7 +718,7 @@ void Command_SaveAll() {
|
|||||||
SaveBuffer(it);
|
SaveBuffer(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} RegisterCommand(Command_SaveAll);
|
||||||
|
|
||||||
int Lua_SaveAll(lua_State *L) {
|
int Lua_SaveAll(lua_State *L) {
|
||||||
Command_SaveAll();
|
Command_SaveAll();
|
||||||
@@ -992,7 +992,7 @@ void Command_Reopen() {
|
|||||||
BSet main = GetBSet(LastActiveLayoutWindowID);
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
ReopenBuffer(main.buffer);
|
ReopenBuffer(main.buffer);
|
||||||
NextActiveWindowID = main.window->id;
|
NextActiveWindowID = main.window->id;
|
||||||
}
|
} RegisterCommand(Command_Reopen);
|
||||||
|
|
||||||
int Lua_Reopen(lua_State *L) {
|
int Lua_Reopen(lua_State *L) {
|
||||||
Command_Reopen();
|
Command_Reopen();
|
||||||
@@ -1016,15 +1016,16 @@ void New(Window *window, String name = "") {
|
|||||||
WindowOpenBufferView(window, name);
|
WindowOpenBufferView(window, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Command_New(String name = "") {
|
void Command_New() {
|
||||||
BSet main = GetBSet(LastActiveLayoutWindowID);
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
New(main.window, name);
|
New(main.window, "");
|
||||||
}
|
} RegisterCommand(Command_New);
|
||||||
|
|
||||||
int Lua_New(lua_State *L) {
|
int Lua_New(lua_State *L) {
|
||||||
String name = lua_tostring(L, 1);
|
String name = lua_tostring(L, 1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
Command_New(name);
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
|
New(main.window, name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1070,7 +1071,7 @@ void Command_ToggleFullscreen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IsInFullscreen = !IsInFullscreen;
|
IsInFullscreen = !IsInFullscreen;
|
||||||
}
|
} RegisterCommand(Command_ToggleFullscreen);
|
||||||
|
|
||||||
int Lua_ToggleFullscreen(lua_State *L) {
|
int Lua_ToggleFullscreen(lua_State *L) {
|
||||||
Command_ToggleFullscreen();
|
Command_ToggleFullscreen();
|
||||||
@@ -1102,7 +1103,7 @@ void Command_ListCode() {
|
|||||||
main.view->fuzzy_search = true;
|
main.view->fuzzy_search = true;
|
||||||
main.view->update_scroll = true;
|
main.view->update_scroll = true;
|
||||||
SelectRange(main.view, GetBufferEndAsRange(main.buffer));
|
SelectRange(main.view, GetBufferEndAsRange(main.buffer));
|
||||||
}
|
} RegisterCommand(Command_ListCode);
|
||||||
|
|
||||||
int Lua_ListCode(lua_State *L) {
|
int Lua_ListCode(lua_State *L) {
|
||||||
Command_ListCode();
|
Command_ListCode();
|
||||||
@@ -1252,7 +1253,7 @@ void Command_ShowBufferList() {
|
|||||||
}
|
}
|
||||||
command_bar.view->update_scroll = true;
|
command_bar.view->update_scroll = true;
|
||||||
SelectRange(command_bar.view, GetBufferEndAsRange(command_bar.buffer));
|
SelectRange(command_bar.view, GetBufferEndAsRange(command_bar.buffer));
|
||||||
}
|
} RegisterCommand(Command_ShowBufferList);
|
||||||
|
|
||||||
void Command_ShowCommandList() {
|
void Command_ShowCommandList() {
|
||||||
BSet command_bar = GetBSet(CommandBarWindowID);
|
BSet command_bar = GetBSet(CommandBarWindowID);
|
||||||
@@ -1265,7 +1266,7 @@ void Command_ShowCommandList() {
|
|||||||
|
|
||||||
command_bar.view->update_scroll = true;
|
command_bar.view->update_scroll = true;
|
||||||
SelectRange(command_bar.view, GetBufferEndAsRange(command_bar.buffer));
|
SelectRange(command_bar.view, GetBufferEndAsRange(command_bar.buffer));
|
||||||
}
|
} RegisterCommand(Command_ShowCommandList);
|
||||||
|
|
||||||
void Command_ListViews() {
|
void Command_ListViews() {
|
||||||
BSet command_bar = GetBSet(CommandBarWindowID);
|
BSet command_bar = GetBSet(CommandBarWindowID);
|
||||||
@@ -1279,7 +1280,7 @@ void Command_ListViews() {
|
|||||||
command_bar.view->fuzzy_search = true;
|
command_bar.view->fuzzy_search = true;
|
||||||
command_bar.view->update_scroll = true;
|
command_bar.view->update_scroll = true;
|
||||||
SelectRange(command_bar.view, GetBufferEndAsRange(command_bar.buffer));
|
SelectRange(command_bar.view, GetBufferEndAsRange(command_bar.buffer));
|
||||||
}
|
} RegisterCommand(Command_ListViews);
|
||||||
|
|
||||||
int Lua_ListViews(lua_State *L) {
|
int Lua_ListViews(lua_State *L) {
|
||||||
Command_ListViews();
|
Command_ListViews();
|
||||||
@@ -1316,7 +1317,7 @@ void SetProjectFile(Buffer *buffer) {
|
|||||||
void Command_SetProjectFile() {
|
void Command_SetProjectFile() {
|
||||||
BSet main = GetBSet(LastActiveLayoutWindowID);
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
SetProjectFile(main.buffer);
|
SetProjectFile(main.buffer);
|
||||||
}
|
} RegisterCommand(Command_SetProjectFile);
|
||||||
|
|
||||||
void Command_SetWorkDir() {
|
void Command_SetWorkDir() {
|
||||||
String dir = lua_tostring(LuaState, -1);
|
String dir = lua_tostring(LuaState, -1);
|
||||||
@@ -1331,7 +1332,7 @@ void Command_SetWorkDir() {
|
|||||||
void Command_SetProject() {
|
void Command_SetProject() {
|
||||||
Command_SetWorkDir();
|
Command_SetWorkDir();
|
||||||
Command_SetProjectFile();
|
Command_SetProjectFile();
|
||||||
}
|
} RegisterCommand(Command_SetProject);
|
||||||
|
|
||||||
int Lua_SetProjectFile(lua_State *L) {
|
int Lua_SetProjectFile(lua_State *L) {
|
||||||
Command_SetProjectFile();
|
Command_SetProjectFile();
|
||||||
@@ -1419,12 +1420,12 @@ String16 FetchLoadWord(void) {
|
|||||||
void Command_ToggleDebug() {
|
void Command_ToggleDebug() {
|
||||||
Window *window = GetWindow(DebugWindowID);
|
Window *window = GetWindow(DebugWindowID);
|
||||||
window->visible = !window->visible;
|
window->visible = !window->visible;
|
||||||
}
|
} RegisterCommand(Command_ToggleDebug);
|
||||||
|
|
||||||
void Command_KillProcess() {
|
void Command_KillProcess() {
|
||||||
BSet main = GetBSet(LastActiveLayoutWindowID);
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
KillProcess(main.view);
|
KillProcess(main.view);
|
||||||
}
|
} RegisterCommand(Command_KillProcess);
|
||||||
|
|
||||||
int Lua_KillProcess(lua_State *L) {
|
int Lua_KillProcess(lua_State *L) {
|
||||||
Command_KillProcess();
|
Command_KillProcess();
|
||||||
@@ -1434,7 +1435,7 @@ int Lua_KillProcess(lua_State *L) {
|
|||||||
void Command_KillWindow() {
|
void Command_KillWindow() {
|
||||||
BSet main = GetBSet(LastActiveLayoutWindowID);
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
main.window->kill = true;
|
main.window->kill = true;
|
||||||
}
|
} RegisterCommand(Command_KillWindow);
|
||||||
|
|
||||||
int Lua_KillWindow(lua_State *L) {
|
int Lua_KillWindow(lua_State *L) {
|
||||||
Command_KillWindow();
|
Command_KillWindow();
|
||||||
|
|||||||
@@ -125,8 +125,6 @@ void OnCommand(Event event) {
|
|||||||
} else if (IsDocumentSelectionValid()) {
|
} else if (IsDocumentSelectionValid()) {
|
||||||
Assert(ScrollbarSelected.id == -1);
|
Assert(ScrollbarSelected.id == -1);
|
||||||
BSet selected = GetBSet(DocumentSelected);
|
BSet selected = GetBSet(DocumentSelected);
|
||||||
|
|
||||||
|
|
||||||
Vec2I mouse = MouseVec2I();
|
Vec2I mouse = MouseVec2I();
|
||||||
// Special case for full-screen where we can have document
|
// Special case for full-screen where we can have document
|
||||||
// aligned with monitor screen in which case mouse cursor cannot
|
// aligned with monitor screen in which case mouse cursor cannot
|
||||||
@@ -134,12 +132,14 @@ void OnCommand(Event event) {
|
|||||||
if (mouse.y == 0 && selected.window->document_rect.min.y == 0) {
|
if (mouse.y == 0 && selected.window->document_rect.min.y == 0) {
|
||||||
float x, y;
|
float x, y;
|
||||||
SDL_GetGlobalMouseState(&x, &y);
|
SDL_GetGlobalMouseState(&x, &y);
|
||||||
|
x = roundf(DPIScale * x);
|
||||||
|
y = roundf(DPIScale * y);
|
||||||
if (y == 0) {
|
if (y == 0) {
|
||||||
mouse.y = -10;
|
mouse.y = -10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Int p = ScreenSpaceToBufferPos(selected.window, selected.view, selected.buffer, mouse);
|
Int p = ScreenSpaceToBufferPos(selected.window, selected.view, selected.buffer, mouse);
|
||||||
Caret &caret = selected.view->carets[0];
|
Caret &caret = selected.view->carets[0];
|
||||||
caret = SetFrontWithAnchor(caret, DocumentAnchor, p);
|
caret = SetFrontWithAnchor(caret, DocumentAnchor, p);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -270,11 +270,11 @@ void FillEventWithBasicData(Event *event) {
|
|||||||
|
|
||||||
float xmouse, ymouse;
|
float xmouse, ymouse;
|
||||||
SDL_GetMouseState(&xmouse, &ymouse);
|
SDL_GetMouseState(&xmouse, &ymouse);
|
||||||
event->xmouse = (int16_t)xmouse;
|
event->xmouse = (int16_t)roundf(DPIScale * xmouse);
|
||||||
event->ymouse = (int16_t)ymouse;
|
event->ymouse = (int16_t)roundf(DPIScale * ymouse);
|
||||||
|
|
||||||
int xwindow, ywindow;
|
int xwindow, ywindow;
|
||||||
SDL_GetWindowSize(SDLWindow, &xwindow, &ywindow);
|
SDL_GetWindowSizeInPixels(SDLWindow, &xwindow, &ywindow);
|
||||||
event->xwindow = xwindow;
|
event->xwindow = xwindow;
|
||||||
event->ywindow = ywindow;
|
event->ywindow = ywindow;
|
||||||
event->text = "";
|
event->text = "";
|
||||||
@@ -305,8 +305,8 @@ Event TranslateSDLEvent(SDL_Event *input_event) {
|
|||||||
|
|
||||||
case SDL_EVENT_MOUSE_BUTTON_DOWN: {
|
case SDL_EVENT_MOUSE_BUTTON_DOWN: {
|
||||||
SDL_MouseButtonEvent &b = input_event->button;
|
SDL_MouseButtonEvent &b = input_event->button;
|
||||||
event.xmouse = (int16_t)b.x;
|
event.xmouse = (int16_t)roundf(DPIScale * b.x);
|
||||||
event.ymouse = (int16_t)b.y;
|
event.ymouse = (int16_t)roundf(DPIScale * b.y);
|
||||||
event.clicks = b.clicks;
|
event.clicks = b.clicks;
|
||||||
if (b.button == SDL_BUTTON_LEFT) {
|
if (b.button == SDL_BUTTON_LEFT) {
|
||||||
event.kind = EVENT_MOUSE_LEFT;
|
event.kind = EVENT_MOUSE_LEFT;
|
||||||
@@ -326,8 +326,8 @@ Event TranslateSDLEvent(SDL_Event *input_event) {
|
|||||||
|
|
||||||
case SDL_EVENT_MOUSE_BUTTON_UP: {
|
case SDL_EVENT_MOUSE_BUTTON_UP: {
|
||||||
SDL_MouseButtonEvent &b = input_event->button;
|
SDL_MouseButtonEvent &b = input_event->button;
|
||||||
event.xmouse = (int16_t)b.x;
|
event.xmouse = (int16_t)roundf(DPIScale * b.x);
|
||||||
event.ymouse = (int16_t)b.y;
|
event.ymouse = (int16_t)roundf(DPIScale * b.y);
|
||||||
if (b.button == SDL_BUTTON_LEFT) {
|
if (b.button == SDL_BUTTON_LEFT) {
|
||||||
event.kind = EVENT_MOUSE_LEFT_UP;
|
event.kind = EVENT_MOUSE_LEFT_UP;
|
||||||
} else if (b.button == SDL_BUTTON_RIGHT) {
|
} else if (b.button == SDL_BUTTON_RIGHT) {
|
||||||
@@ -346,10 +346,10 @@ Event TranslateSDLEvent(SDL_Event *input_event) {
|
|||||||
case SDL_EVENT_MOUSE_WHEEL: {
|
case SDL_EVENT_MOUSE_WHEEL: {
|
||||||
event.kind = EVENT_MOUSE_WHEEL;
|
event.kind = EVENT_MOUSE_WHEEL;
|
||||||
SDL_MouseWheelEvent &b = input_event->wheel;
|
SDL_MouseWheelEvent &b = input_event->wheel;
|
||||||
event.xmouse = (int16_t)b.mouse_x;
|
event.xmouse = (int16_t)roundf(DPIScale * b.x);
|
||||||
event.ymouse = (int16_t)b.mouse_y;
|
event.ymouse = (int16_t)roundf(DPIScale * b.y);
|
||||||
event.xwheel = b.x;
|
event.xwheel = b.x;
|
||||||
event.ywheel = b.y;
|
event.ywheel = b.y;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case SDL_EVENT_MOUSE_MOTION: {
|
case SDL_EVENT_MOUSE_MOTION: {
|
||||||
|
|||||||
@@ -184,4 +184,19 @@ void ReloadStyle() {
|
|||||||
StyleFont = GetStyleString("Font", StyleFont);
|
StyleFont = GetStyleString("Font", StyleFont);
|
||||||
StyleVCVarsall = GetStyleString("VCVarsall", StyleVCVarsall);
|
StyleVCVarsall = GetStyleString("VCVarsall", StyleVCVarsall);
|
||||||
StyleUndoMergeTimeout = GetStyleFloat("UndoMergeTimeout", StyleUndoMergeTimeout);
|
StyleUndoMergeTimeout = GetStyleFloat("UndoMergeTimeout", StyleUndoMergeTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef void CommandFunction(void);
|
||||||
|
Array<CommandFunction *> CommandFunctions;
|
||||||
|
|
||||||
|
#define STRINGIFY_(x) x
|
||||||
|
#define STRINGIFY(x) STRINGIFY_(x)
|
||||||
|
#define CONCAT_(a, b) a ## b
|
||||||
|
#define CONCAT(a, b) CONCAT_(a, b)
|
||||||
|
|
||||||
|
struct Register_Command {
|
||||||
|
Register_Command(CommandFunction *f) {
|
||||||
|
Add(&CommandFunctions, f);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#define RegisterCommand(NAME) Register_Command CONCAT(COMMAND, __COUNTER__)(NAME)
|
||||||
@@ -7,6 +7,9 @@
|
|||||||
#include "external/glad/glad.h"
|
#include "external/glad/glad.h"
|
||||||
#include "external/stb_truetype.h"
|
#include "external/stb_truetype.h"
|
||||||
#include "external/stb_truetype.c"
|
#include "external/stb_truetype.c"
|
||||||
|
#if OS_LINUX
|
||||||
|
#define MCO_USE_UCONTEXT
|
||||||
|
#endif
|
||||||
#define MINICORO_IMPL
|
#define MINICORO_IMPL
|
||||||
#include "external/minicoro.h"
|
#include "external/minicoro.h"
|
||||||
#define LUA_USE_LONGJMP
|
#define LUA_USE_LONGJMP
|
||||||
@@ -198,7 +201,7 @@ void MainLoop() {
|
|||||||
|
|
||||||
if (it.xwindow == 0 || it.ywindow == 0) {
|
if (it.xwindow == 0 || it.ywindow == 0) {
|
||||||
int xwindow, ywindow;
|
int xwindow, ywindow;
|
||||||
SDL_GetWindowSize(SDLWindow, &xwindow, &ywindow);
|
SDL_GetWindowSizeInPixels(SDLWindow, &xwindow, &ywindow);
|
||||||
it.xwindow = xwindow;
|
it.xwindow = xwindow;
|
||||||
it.ywindow = ywindow;
|
it.ywindow = ywindow;
|
||||||
}
|
}
|
||||||
@@ -312,7 +315,7 @@ int main(int argc, char **argv)
|
|||||||
int yhalf = 30;
|
int yhalf = 30;
|
||||||
|
|
||||||
Uint32 window_flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIGH_PIXEL_DENSITY;
|
Uint32 window_flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIGH_PIXEL_DENSITY;
|
||||||
SDLWindow = SDL_CreateWindow("Text editor", whalf, hhalf, window_flags);
|
SDLWindow = SDL_CreateWindow("Text editor", whalf, hhalf, window_flags);
|
||||||
if (SDLWindow == NULL) {
|
if (SDLWindow == NULL) {
|
||||||
ReportErrorf("Couldn't create window! %s", SDL_GetError());
|
ReportErrorf("Couldn't create window! %s", SDL_GetError());
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ void UpdateDebugBuffer() {
|
|||||||
|
|
||||||
float xmouse, ymouse;
|
float xmouse, ymouse;
|
||||||
SDL_GetMouseState(&xmouse, &ymouse);
|
SDL_GetMouseState(&xmouse, &ymouse);
|
||||||
RawAppendf(buffer, "mouse: [%f, %f]\n", xmouse, ymouse);
|
RawAppendf(buffer, "mouse: [%f, %f]\n", roundf(DPIScale * xmouse), roundf(DPIScale * ymouse));
|
||||||
|
|
||||||
RawAppendf(buffer, "BufferID id = %d\n", main.buffer->id.id);
|
RawAppendf(buffer, "BufferID id = %d\n", main.buffer->id.id);
|
||||||
RawAppendf(buffer, "String name = %S\n", main.buffer->name);
|
RawAppendf(buffer, "String name = %S\n", main.buffer->name);
|
||||||
|
|||||||
Reference in New Issue
Block a user