New keycodes; linux one time code execution; close file handle in save function

master
Allen Webster 2020-03-03 18:44:25 -08:00
parent bc2b834f3b
commit 7933ec6bc9
14 changed files with 377 additions and 208 deletions

View File

@ -123,9 +123,20 @@ make_key_list(Arena *arena){
add_code(arena, &list, string_u8_litexpr("Control")); add_code(arena, &list, string_u8_litexpr("Control"));
add_code(arena, &list, string_u8_litexpr("Alt")); add_code(arena, &list, string_u8_litexpr("Alt"));
add_code(arena, &list, string_u8_litexpr("Command")); add_code(arena, &list, string_u8_litexpr("Command"));
for (u32 i = 1; i <= 16; i += 1){ for (u32 i = 1; i <= 24; i += 1){
add_code(arena, &list, push_u8_stringf(arena, "F%d", i)); add_code(arena, &list, push_u8_stringf(arena, "F%d", i));
} }
for (u32 i = '0'; i <= '9'; i += 1){
add_code(arena, &list, push_u8_stringf(arena, "NumPad%c", i));
}
add_code(arena, &list, string_u8_litexpr("NumPadStar"));
add_code(arena, &list, string_u8_litexpr("NumPadPlus"));
add_code(arena, &list, string_u8_litexpr("NumPadMinus"));
add_code(arena, &list, string_u8_litexpr("NumPadDot"));
add_code(arena, &list, string_u8_litexpr("NumPadSlash"));
for (i32 i = 0; i < 30; i += 1){
add_code(arena, &list, push_u8_stringf(arena, "Ex%d", i));
}
return(list); return(list);
} }

0
bin/itchio_push_all.sh Normal file → Executable file
View File

0
bin/itchio_push_linux-x86.sh Normal file → Executable file
View File

0
bin/itchio_push_linux.sh Normal file → Executable file
View File

0
bin/package-x86-linux.sh Normal file → Executable file
View File

42
custom/bin/build_one_time.sh Executable file
View File

@ -0,0 +1,42 @@
#!/bin/bash
# If any command errors, stop the script
set -e
# Set up directories
ORIGINAL=$PWD
ME="$(readlink -f "$0")"
LOCATION="$(dirname "$ME")"
cd $LOCATION
cd ..
CUSTOM_ROOT=$PWD
cd $ORIGINAL
target=$1
if [ -z "$target" ]
then
echo error: no input file
exit 1
fi
full_target=$target
if [[ ${target:0:1} != "/" ]];
then
full_target="$PWD/$target"
fi
dst=$2
if [[ $dst == "" ]];
then
dst=.
fi
debug=-g
opts="-Wno-write-strings -Wno-null-dereference -Wno-comment -Wno-switch -Wno-missing-declarations -Wno-logical-op-parentheses -g -DOS_LINUX=1 -DOS_WINDOWS=0 -DOS_MAC=0"
pushd $dst
g++ -I"$CUSTOM_ROOT" $opts $full_target -o one_time
popd

View File

@ -15,9 +15,11 @@ if [ -z "$SOURCE" ]; then
fi fi
echo SOURCE = $SOURCE echo SOURCE = $SOURCE
opts="-Wno-write-strings -Wno-null-dereference -Wno-comment -Wno-switch -Wno-missing-declarations -Wno-logical-op-parentheses -g -DOS_LINUX=1 -DOS_WINDOWS=0 -DOS_MAC=1" opts="-Wno-write-strings -Wno-null-dereference -Wno-comment -Wno-switch -Wno-missing-declarations -Wno-logical-op-parentheses -g -DOS_LINUX=1 -DOS_WINDOWS=0 -DOS_MAC=0"
arch=-m64 arch=-m64
debug=-g
preproc_file=4coder_command_metadata.i preproc_file=4coder_command_metadata.i
meta_macros="-DMETA_PASS" meta_macros="-DMETA_PASS"
g++ -I"$CODE_HOME" $meta_macros $arch $opts $debug -std=c++11 "$SOURCE" -E -o $preproc_file g++ -I"$CODE_HOME" $meta_macros $arch $opts $debug -std=c++11 "$SOURCE" -E -o $preproc_file

View File

@ -18,6 +18,8 @@ fi
opts="-Wno-write-strings -Wno-null-dereference -Wno-comment -Wno-switch -Wno-missing-declarations -Wno-logical-op-parentheses -g -DOS_MAC=1 -DOS_WINDOWS=0 -DOS_LINUX=0" opts="-Wno-write-strings -Wno-null-dereference -Wno-comment -Wno-switch -Wno-missing-declarations -Wno-logical-op-parentheses -g -DOS_MAC=1 -DOS_WINDOWS=0 -DOS_LINUX=0"
arch=-m64 arch=-m64
debug=-g
preproc_file=4coder_command_metadata.i preproc_file=4coder_command_metadata.i
meta_macros="-DMETA_PASS" meta_macros="-DMETA_PASS"
clang++ -I"$CODE_HOME" $meta_macros $arch $opts $debug -std=c++11 "$SOURCE" -E -o $preproc_file clang++ -I"$CODE_HOME" $meta_macros $arch $opts $debug -std=c++11 "$SOURCE" -E -o $preproc_file

View File

@ -14,9 +14,11 @@ if [ -z "$SOURCE" ]; then
SOURCE="$(readlink -f "$CODE_HOME/4coder_default_bindings.cpp")" SOURCE="$(readlink -f "$CODE_HOME/4coder_default_bindings.cpp")"
fi fi
opts="-Wno-write-strings -Wno-null-dereference -Wno-comment -Wno-switch -Wno-missing-declarations -Wno-logical-op-parentheses -g -DOS_LINUX=1 -DOS_WINDOWS=0 -DOS_MAC=1" opts="-Wno-write-strings -Wno-null-dereference -Wno-comment -Wno-switch -Wno-missing-declarations -Wno-logical-op-parentheses -g -DOS_LINUX=1 -DOS_WINDOWS=0 -DOS_MAC=0"
arch=-m32 arch=-m32
debug=-g
preproc_file=4coder_command_metadata.i preproc_file=4coder_command_metadata.i
meta_macros="-DMETA_PASS" meta_macros="-DMETA_PASS"
g++ -I"$CODE_HOME" $meta_macros $arch $opts $debug -std=c++11 "$SOURCE" -E -o $preproc_file g++ -I"$CODE_HOME" $meta_macros $arch $opts $debug -std=c++11 "$SOURCE" -E -o $preproc_file

View File

@ -1,212 +1,318 @@
enum{ enum{
KeyCode_A = 1, KeyCode_A = 1,
KeyCode_B = 2, KeyCode_B = 2,
KeyCode_C = 3, KeyCode_C = 3,
KeyCode_D = 4, KeyCode_D = 4,
KeyCode_E = 5, KeyCode_E = 5,
KeyCode_F = 6, KeyCode_F = 6,
KeyCode_G = 7, KeyCode_G = 7,
KeyCode_H = 8, KeyCode_H = 8,
KeyCode_I = 9, KeyCode_I = 9,
KeyCode_J = 10, KeyCode_J = 10,
KeyCode_K = 11, KeyCode_K = 11,
KeyCode_L = 12, KeyCode_L = 12,
KeyCode_M = 13, KeyCode_M = 13,
KeyCode_N = 14, KeyCode_N = 14,
KeyCode_O = 15, KeyCode_O = 15,
KeyCode_P = 16, KeyCode_P = 16,
KeyCode_Q = 17, KeyCode_Q = 17,
KeyCode_R = 18, KeyCode_R = 18,
KeyCode_S = 19, KeyCode_S = 19,
KeyCode_T = 20, KeyCode_T = 20,
KeyCode_U = 21, KeyCode_U = 21,
KeyCode_V = 22, KeyCode_V = 22,
KeyCode_W = 23, KeyCode_W = 23,
KeyCode_X = 24, KeyCode_X = 24,
KeyCode_Y = 25, KeyCode_Y = 25,
KeyCode_Z = 26, KeyCode_Z = 26,
KeyCode_0 = 27, KeyCode_0 = 27,
KeyCode_1 = 28, KeyCode_1 = 28,
KeyCode_2 = 29, KeyCode_2 = 29,
KeyCode_3 = 30, KeyCode_3 = 30,
KeyCode_4 = 31, KeyCode_4 = 31,
KeyCode_5 = 32, KeyCode_5 = 32,
KeyCode_6 = 33, KeyCode_6 = 33,
KeyCode_7 = 34, KeyCode_7 = 34,
KeyCode_8 = 35, KeyCode_8 = 35,
KeyCode_9 = 36, KeyCode_9 = 36,
KeyCode_Space = 37, KeyCode_Space = 37,
KeyCode_Tick = 38, KeyCode_Tick = 38,
KeyCode_Minus = 39, KeyCode_Minus = 39,
KeyCode_Equal = 40, KeyCode_Equal = 40,
KeyCode_LeftBracket = 41, KeyCode_LeftBracket = 41,
KeyCode_RightBracket = 42, KeyCode_RightBracket = 42,
KeyCode_Semicolon = 43, KeyCode_Semicolon = 43,
KeyCode_Quote = 44, KeyCode_Quote = 44,
KeyCode_Comma = 45, KeyCode_Comma = 45,
KeyCode_Period = 46, KeyCode_Period = 46,
KeyCode_ForwardSlash = 47, KeyCode_ForwardSlash = 47,
KeyCode_BackwardSlash = 48, KeyCode_BackwardSlash = 48,
KeyCode_Tab = 49, KeyCode_Tab = 49,
KeyCode_Escape = 50, KeyCode_Escape = 50,
KeyCode_Pause = 51, KeyCode_Pause = 51,
KeyCode_Up = 52, KeyCode_Up = 52,
KeyCode_Down = 53, KeyCode_Down = 53,
KeyCode_Left = 54, KeyCode_Left = 54,
KeyCode_Right = 55, KeyCode_Right = 55,
KeyCode_Backspace = 56, KeyCode_Backspace = 56,
KeyCode_Return = 57, KeyCode_Return = 57,
KeyCode_Delete = 58, KeyCode_Delete = 58,
KeyCode_Insert = 59, KeyCode_Insert = 59,
KeyCode_Home = 60, KeyCode_Home = 60,
KeyCode_End = 61, KeyCode_End = 61,
KeyCode_PageUp = 62, KeyCode_PageUp = 62,
KeyCode_PageDown = 63, KeyCode_PageDown = 63,
KeyCode_CapsLock = 64, KeyCode_CapsLock = 64,
KeyCode_NumLock = 65, KeyCode_NumLock = 65,
KeyCode_ScrollLock = 66, KeyCode_ScrollLock = 66,
KeyCode_Menu = 67, KeyCode_Menu = 67,
KeyCode_Shift = 68, KeyCode_Shift = 68,
KeyCode_Control = 69, KeyCode_Control = 69,
KeyCode_Alt = 70, KeyCode_Alt = 70,
KeyCode_Command = 71, KeyCode_Command = 71,
KeyCode_F1 = 72, KeyCode_F1 = 72,
KeyCode_F2 = 73, KeyCode_F2 = 73,
KeyCode_F3 = 74, KeyCode_F3 = 74,
KeyCode_F4 = 75, KeyCode_F4 = 75,
KeyCode_F5 = 76, KeyCode_F5 = 76,
KeyCode_F6 = 77, KeyCode_F6 = 77,
KeyCode_F7 = 78, KeyCode_F7 = 78,
KeyCode_F8 = 79, KeyCode_F8 = 79,
KeyCode_F9 = 80, KeyCode_F9 = 80,
KeyCode_F10 = 81, KeyCode_F10 = 81,
KeyCode_F11 = 82, KeyCode_F11 = 82,
KeyCode_F12 = 83, KeyCode_F12 = 83,
KeyCode_F13 = 84, KeyCode_F13 = 84,
KeyCode_F14 = 85, KeyCode_F14 = 85,
KeyCode_F15 = 86, KeyCode_F15 = 86,
KeyCode_F16 = 87, KeyCode_F16 = 87,
KeyCode_COUNT = 88, KeyCode_F17 = 88,
KeyCode_F18 = 89,
KeyCode_F19 = 90,
KeyCode_F20 = 91,
KeyCode_F21 = 92,
KeyCode_F22 = 93,
KeyCode_F23 = 94,
KeyCode_F24 = 95,
KeyCode_NumPad0 = 96,
KeyCode_NumPad1 = 97,
KeyCode_NumPad2 = 98,
KeyCode_NumPad3 = 99,
KeyCode_NumPad4 = 100,
KeyCode_NumPad5 = 101,
KeyCode_NumPad6 = 102,
KeyCode_NumPad7 = 103,
KeyCode_NumPad8 = 104,
KeyCode_NumPad9 = 105,
KeyCode_NumPadStar = 106,
KeyCode_NumPadPlus = 107,
KeyCode_NumPadMinus = 108,
KeyCode_NumPadDot = 109,
KeyCode_NumPadSlash = 110,
KeyCode_Ex0 = 111,
KeyCode_Ex1 = 112,
KeyCode_Ex2 = 113,
KeyCode_Ex3 = 114,
KeyCode_Ex4 = 115,
KeyCode_Ex5 = 116,
KeyCode_Ex6 = 117,
KeyCode_Ex7 = 118,
KeyCode_Ex8 = 119,
KeyCode_Ex9 = 120,
KeyCode_Ex10 = 121,
KeyCode_Ex11 = 122,
KeyCode_Ex12 = 123,
KeyCode_Ex13 = 124,
KeyCode_Ex14 = 125,
KeyCode_Ex15 = 126,
KeyCode_Ex16 = 127,
KeyCode_Ex17 = 128,
KeyCode_Ex18 = 129,
KeyCode_Ex19 = 130,
KeyCode_Ex20 = 131,
KeyCode_Ex21 = 132,
KeyCode_Ex22 = 133,
KeyCode_Ex23 = 134,
KeyCode_Ex24 = 135,
KeyCode_Ex25 = 136,
KeyCode_Ex26 = 137,
KeyCode_Ex27 = 138,
KeyCode_Ex28 = 139,
KeyCode_Ex29 = 140,
KeyCode_COUNT = 141,
}; };
global char* key_code_name[KeyCode_COUNT] = { global char* key_code_name[KeyCode_COUNT] = {
"None", "None",
"A", "A",
"B", "B",
"C", "C",
"D", "D",
"E", "E",
"F", "F",
"G", "G",
"H", "H",
"I", "I",
"J", "J",
"K", "K",
"L", "L",
"M", "M",
"N", "N",
"O", "O",
"P", "P",
"Q", "Q",
"R", "R",
"S", "S",
"T", "T",
"U", "U",
"V", "V",
"W", "W",
"X", "X",
"Y", "Y",
"Z", "Z",
"0", "0",
"1", "1",
"2", "2",
"3", "3",
"4", "4",
"5", "5",
"6", "6",
"7", "7",
"8", "8",
"9", "9",
"Space", "Space",
"Tick", "Tick",
"Minus", "Minus",
"Equal", "Equal",
"LeftBracket", "LeftBracket",
"RightBracket", "RightBracket",
"Semicolon", "Semicolon",
"Quote", "Quote",
"Comma", "Comma",
"Period", "Period",
"ForwardSlash", "ForwardSlash",
"BackwardSlash", "BackwardSlash",
"Tab", "Tab",
"Escape", "Escape",
"Pause", "Pause",
"Up", "Up",
"Down", "Down",
"Left", "Left",
"Right", "Right",
"Backspace", "Backspace",
"Return", "Return",
"Delete", "Delete",
"Insert", "Insert",
"Home", "Home",
"End", "End",
"PageUp", "PageUp",
"PageDown", "PageDown",
"CapsLock", "CapsLock",
"NumLock", "NumLock",
"ScrollLock", "ScrollLock",
"Menu", "Menu",
"Shift", "Shift",
"Control", "Control",
"Alt", "Alt",
"Command", "Command",
"F1", "F1",
"F2", "F2",
"F3", "F3",
"F4", "F4",
"F5", "F5",
"F6", "F6",
"F7", "F7",
"F8", "F8",
"F9", "F9",
"F10", "F10",
"F11", "F11",
"F12", "F12",
"F13", "F13",
"F14", "F14",
"F15", "F15",
"F16", "F16",
"F17",
"F18",
"F19",
"F20",
"F21",
"F22",
"F23",
"F24",
"NumPad0",
"NumPad1",
"NumPad2",
"NumPad3",
"NumPad4",
"NumPad5",
"NumPad6",
"NumPad7",
"NumPad8",
"NumPad9",
"NumPadStar",
"NumPadPlus",
"NumPadMinus",
"NumPadDot",
"NumPadSlash",
"Ex0",
"Ex1",
"Ex2",
"Ex3",
"Ex4",
"Ex5",
"Ex6",
"Ex7",
"Ex8",
"Ex9",
"Ex10",
"Ex11",
"Ex12",
"Ex13",
"Ex14",
"Ex15",
"Ex16",
"Ex17",
"Ex18",
"Ex19",
"Ex20",
"Ex21",
"Ex22",
"Ex23",
"Ex24",
"Ex25",
"Ex26",
"Ex27",
"Ex28",
"Ex29",
}; };
enum{ enum{
MouseCode_Left = 1, MouseCode_Left = 1,
MouseCode_Middle = 2, MouseCode_Middle = 2,
MouseCode_Right = 3, MouseCode_Right = 3,
MouseCode_COUNT = 4, MouseCode_COUNT = 4,
}; };
global char* mouse_code_name[MouseCode_COUNT] = { global char* mouse_code_name[MouseCode_COUNT] = {
"None", "None",
"Left", "Left",
"Middle", "Middle",
"Right", "Right",
}; };
enum{ enum{
CoreCode_Startup = 1, CoreCode_Startup = 1,
CoreCode_Animate = 2, CoreCode_Animate = 2,
CoreCode_ClickActivateView = 3, CoreCode_ClickActivateView = 3,
CoreCode_ClickDeactivateView = 4, CoreCode_ClickDeactivateView = 4,
CoreCode_TryExit = 5, CoreCode_TryExit = 5,
CoreCode_FileExternallyModified = 6, CoreCode_FileExternallyModified = 6,
CoreCode_NewClipboardContents = 7, CoreCode_NewClipboardContents = 7,
CoreCode_COUNT = 8, CoreCode_COUNT = 8,
}; };
global char* core_code_name[CoreCode_COUNT] = { global char* core_code_name[CoreCode_COUNT] = {
"None", "None",
"Startup", "Startup",
"Animate", "Animate",
"ClickActivateView", "ClickActivateView",
"ClickDeactivateView", "ClickDeactivateView",
"TryExit", "TryExit",
"FileExternallyModified", "FileExternallyModified",
"NewClipboardContents", "NewClipboardContents",
}; };

View File

@ -1080,7 +1080,7 @@ linux_keycode_init(Display* dpy){
// Find the rest by their key label // Find the rest by their key label
struct SymCode { KeySym sym; Key_Code code; }; struct SymCode { KeySym sym; Key_Code code; };
SymCode sym_table[100]; SymCode sym_table[108];
SymCode* p = sym_table; SymCode* p = sym_table;
*p++ = { XK_space, KeyCode_Space }; *p++ = { XK_space, KeyCode_Space };
@ -1112,7 +1112,7 @@ linux_keycode_init(Display* dpy){
*p++ = { XK_Super_L, KeyCode_Command }; *p++ = { XK_Super_L, KeyCode_Command };
*p++ = { XK_Super_R, KeyCode_Command }; *p++ = { XK_Super_R, KeyCode_Command };
for(Key_Code k = KeyCode_F1; k <= KeyCode_F16; ++k) { for (Key_Code k = KeyCode_F1; k <= KeyCode_F24; ++k){
*p++ = { XK_F1 + (k - KeyCode_F1), k }; *p++ = { XK_F1 + (k - KeyCode_F1), k };
} }

View File

@ -233,6 +233,7 @@ system_save_file(Arena* scratch, char* file_name, String_Const_u8 data){
result = linux_file_attributes_from_struct_stat(&file_stat); result = linux_file_attributes_from_struct_stat(&file_stat);
} }
} }
close(fd);
} else { } else {
perror("open"); perror("open");
} }

View File

@ -53,8 +53,8 @@ command_list = {
{ .name = "run one time", { .name = "run one time",
.out = "*run*", .footer_panel = false, .save_dirty_files = false, .out = "*run*", .footer_panel = false, .save_dirty_files = false,
.cmd = { { "pushd ..\\build & one_time", .os = "win" }, .cmd = { { "pushd ..\\build & one_time", .os = "win" },
{ "pushd ../build & one_time", .os = "linux" }, { "cd ../build && ./one_time" , .os = "linux" },
{ "pushd ../build & one_time", .os = "mac" }, }, }, { "pushd ../build && ./one_time" , .os = "mac" }, }, },
{ .name = "build custom api docs", { .name = "build custom api docs",
.out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .out = "*compilation*", .footer_panel = true, .save_dirty_files = true,
@ -92,7 +92,8 @@ command_list = {
{ .name = "build keycode generator", { .name = "build keycode generator",
.out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .out = "*compilation*", .footer_panel = true, .save_dirty_files = true,
.cmd = { { "custom\\bin\\build_one_time 4ed_generate_keycodes.cpp ..\\build", .os = "win" }, }, }, .cmd = { { "custom\\bin\\build_one_time 4ed_generate_keycodes.cpp ..\\build", .os = "win" },
{ "custom/bin/build_one_time.sh 4ed_generate_keycodes.cpp ../build", .os = "linux" }, }, },
{ .name = "build site render", { .name = "build site render",
.out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .out = "*compilation*", .footer_panel = true, .save_dirty_files = true,

View File

@ -7,6 +7,8 @@
+ in config.4coder the variable virtual_whitespace_regular_indent determines the number of space-widths to use as the regular indentation in a virtual whitespace layout + in config.4coder the variable virtual_whitespace_regular_indent determines the number of space-widths to use as the regular indentation in a virtual whitespace layout
+ show whitespace mode implemented in 'default_render_buffer' + show whitespace mode implemented in 'default_render_buffer'
+ `set_face_size` and `set_face_size_this_buffer` commands + `set_face_size` and `set_face_size_this_buffer` commands
+ `HookID_WholeScreenRenderCaller` hook runs once per frame after all views render
+ Extended key codes list
+ Fix: tabs are measured with the correct amount of width for the user's settings + Fix: tabs are measured with the correct amount of width for the user's settings
+ Fix: virtual whitespace toggling works when the config initially diabled virtual whitespace + Fix: virtual whitespace toggling works when the config initially diabled virtual whitespace
+ Fix: never miss the most recent post to the clipboard on windows + Fix: never miss the most recent post to the clipboard on windows