Improve ApplyRules
This commit is contained in:
@@ -176,6 +176,15 @@ char *C(const char *value) {
|
||||
}
|
||||
|
||||
S8_String LuaScript = R"==(
|
||||
KEY_CTRL = 1073742048
|
||||
KEY_PAGE_DOWN = 1073741902
|
||||
KEY_PAGE_UP = 1073741899
|
||||
KEY_DOWN = 1073741905 -- 0x40000051
|
||||
KEY_UP = 1073741906 -- 0x40000052u
|
||||
KEY_RIGHT = 1073741903
|
||||
KEY_LEFT = 1073741904
|
||||
KEY_Q = 113
|
||||
|
||||
function SkipLineAndColumn(s)
|
||||
local line, col = "1", "1"
|
||||
|
||||
@@ -294,7 +303,11 @@ function MatchWindowsPath(_s)
|
||||
end
|
||||
local line, col, s = SkipLineAndColumn(s)
|
||||
|
||||
print("OPEN :: INPUT = ".._s.." KIND = ".."text".." ".."FILE_PATH = "..file_path.."["..line..","..col.."]")
|
||||
local exists = FileExists(file_path) or BufferNameExists(file_path)
|
||||
if not exists then return nil end
|
||||
|
||||
|
||||
Print("OPEN :: INPUT = ".._s.." KIND = ".."text".." ".."FILE_PATH = "..file_path.."["..line..","..col.."]")
|
||||
return {kind = "text", file_path = file_path, line = line, col = col}
|
||||
end
|
||||
|
||||
@@ -303,7 +316,16 @@ function MatchGitCommit(s)
|
||||
if i then
|
||||
s = s:sub(8)
|
||||
local command = "git --no-pager show "..s
|
||||
return {kind = "exec", cmd = command, working_dir = GetActiveMainWindowBufferName()}
|
||||
return {kind = "exec", cmd = command, working_dir = GetActiveMainWindowBufferDir()}
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
InternetBrowser = 'C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe'
|
||||
function MatchURL(s)
|
||||
local i, j = string.find(s, "^https://")
|
||||
if i then
|
||||
return {kind = "exec_console", cmd = '"'..InternetBrowser..'" '..s, working_dir = GetActiveMainWindowBufferDir()}
|
||||
end
|
||||
return nil
|
||||
end
|
||||
@@ -311,6 +333,7 @@ end
|
||||
Rules = {
|
||||
MatchWindowsPath,
|
||||
MatchGitCommit,
|
||||
MatchURL,
|
||||
}
|
||||
|
||||
function ApplyRules(s)
|
||||
|
||||
@@ -36,6 +36,8 @@ This page contains characters from each of the Unicode character blocks.
|
||||
|
||||
See also Unicode 3.2 test page.
|
||||
|
||||
commit 225d1ffc067da0723898ade68fb9492bbe308feb
|
||||
https://www.lua.org/manual/5.4/
|
||||
C:\Work\text_editor\src\text_editor\buffer_history.cpp
|
||||
|
||||
Basic Latin
|
||||
|
||||
@@ -478,6 +478,7 @@ void GlobalCommand(Event event) {
|
||||
ActiveWindow = GetActiveMainSet().window->id;
|
||||
} else {
|
||||
active.view->carets.len = 1;
|
||||
active.view->carets[0] = MakeCaret(GetFront(active.view->carets[0]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,15 @@ Style.FontSize = 12
|
||||
Style.FontFilter = 0
|
||||
Style.Font = "C:/Windows/Fonts/consola.ttf"
|
||||
|
||||
KEY_CTRL = 1073742048
|
||||
KEY_PAGE_DOWN = 1073741902
|
||||
KEY_PAGE_UP = 1073741899
|
||||
KEY_DOWN = 1073741905 -- 0x40000051
|
||||
KEY_UP = 1073741906 -- 0x40000052u
|
||||
KEY_RIGHT = 1073741903
|
||||
KEY_LEFT = 1073741904
|
||||
KEY_Q = 113
|
||||
|
||||
function SkipLineAndColumn(s)
|
||||
local line, col = "1", "1"
|
||||
|
||||
@@ -184,7 +193,11 @@ function MatchWindowsPath(_s)
|
||||
end
|
||||
local line, col, s = SkipLineAndColumn(s)
|
||||
|
||||
print("OPEN :: INPUT = ".._s.." KIND = ".."text".." ".."FILE_PATH = "..file_path.."["..line..","..col.."]")
|
||||
local exists = FileExists(file_path) or BufferNameExists(file_path)
|
||||
if not exists then return nil end
|
||||
|
||||
|
||||
Print("OPEN :: INPUT = ".._s.." KIND = ".."text".." ".."FILE_PATH = "..file_path.."["..line..","..col.."]")
|
||||
return {kind = "text", file_path = file_path, line = line, col = col}
|
||||
end
|
||||
|
||||
@@ -193,7 +206,16 @@ function MatchGitCommit(s)
|
||||
if i then
|
||||
s = s:sub(8)
|
||||
local command = "git --no-pager show "..s
|
||||
return {kind = "exec", cmd = command, working_dir = GetActiveMainWindowBufferName()}
|
||||
return {kind = "exec", cmd = command, working_dir = GetActiveMainWindowBufferDir()}
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
InternetBrowser = 'C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe'
|
||||
function MatchURL(s)
|
||||
local i, j = string.find(s, "^https://")
|
||||
if i then
|
||||
return {kind = "exec_console", cmd = '"'..InternetBrowser..'" '..s, working_dir = GetActiveMainWindowBufferDir()}
|
||||
end
|
||||
return nil
|
||||
end
|
||||
@@ -201,6 +223,7 @@ end
|
||||
Rules = {
|
||||
MatchWindowsPath,
|
||||
MatchGitCommit,
|
||||
MatchURL,
|
||||
}
|
||||
|
||||
function ApplyRules(s)
|
||||
|
||||
@@ -63,6 +63,10 @@ void Open(String path) {
|
||||
String cmd = FieldString(LuaState, "cmd");
|
||||
String working_dir = FieldString(LuaState, "working_dir");
|
||||
ExecInNewBuffer(cmd, working_dir);
|
||||
} else if (FieldString(LuaState, "kind") == "exec_console") {
|
||||
String cmd = FieldString(LuaState, "cmd");
|
||||
String working_dir = FieldString(LuaState, "working_dir");
|
||||
Exec(NullViewID, true, cmd, working_dir);
|
||||
} else {
|
||||
ReportWarningf("Failed to match any of ApplyRules results!");
|
||||
}
|
||||
|
||||
@@ -426,7 +426,7 @@ void GarbageCollect() {
|
||||
remove_item = true;
|
||||
// @todo: add view to free list
|
||||
|
||||
IKnowWhatImDoing_Appendf(GCInfoBuffer, "view %.*s", FmtString(buffer->name));
|
||||
IKnowWhatImDoing_Appendf(GCInfoBuffer, "view %.*s\n", FmtString(buffer->name));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -444,7 +444,7 @@ void GarbageCollect() {
|
||||
remove_item = true;
|
||||
// @todo: add buffer to free list
|
||||
|
||||
IKnowWhatImDoing_Appendf(GCInfoBuffer, "buffer %.*s", FmtString(buffer->name));
|
||||
IKnowWhatImDoing_Appendf(GCInfoBuffer, "buffer %.*s\n", FmtString(buffer->name));
|
||||
} else if (buffer->file_mod_time) {
|
||||
int64_t new_file_mod_time = GetFileModTime(buffer->name);
|
||||
if (buffer->file_mod_time != new_file_mod_time) {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
- Fuzzy search buffer which uses titlebar as query!
|
||||
- Check if file exists in ApplyRules otherwise return null
|
||||
- Gotos, jumping between views should preserve cursors
|
||||
- Gotos, jumping between views should preserve cursors, maybe just scroll
|
||||
- ReportWarning should be signaled visibly but you should be able to do things! no focus switching
|
||||
|
||||
- OnWindowCommand allow config user to overwrite the WindowCommand keybinding, introduce his own
|
||||
|
||||
Reference in New Issue
Block a user