Exec command as meta to Open
This commit is contained in:
@@ -79,8 +79,7 @@ Int ScreenSpaceToBufferPosErrorOutOfBounds(Window *window, View *view, Buffer *b
|
||||
return result;
|
||||
}
|
||||
|
||||
void Command_OpenForLoadWord(String16 string) { Command_Open(string); }
|
||||
void MouseLoadWord(Event event, void (*cmd_function)(String16 string)) {
|
||||
void MouseLoadWord(Event event, String meta = "") {
|
||||
Vec2I mouse = MouseVec2I();
|
||||
BSet active = GetActiveSet();
|
||||
|
||||
@@ -94,7 +93,7 @@ void MouseLoadWord(Event event, void (*cmd_function)(String16 string)) {
|
||||
|
||||
active.view->carets.len = 1;
|
||||
active.view->carets[0] = MakeCaret(p);
|
||||
cmd_function(string);
|
||||
Command_Open(string, meta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,9 +314,9 @@ void OnCommand(Event event) {
|
||||
}
|
||||
|
||||
if (Shift() && Ctrl() && Mouse(LEFT)) {
|
||||
MouseLoadWord(event, Command_Eval);
|
||||
MouseLoadWord(event, "exec");
|
||||
} else if (Ctrl() && Mouse(LEFT)) {
|
||||
MouseLoadWord(event, Command_OpenForLoadWord);
|
||||
MouseLoadWord(event);
|
||||
} else if (Mouse(LEFT)) { // Uses Alt and shift
|
||||
Vec2I mouse = MouseVec2I();
|
||||
{
|
||||
@@ -695,7 +695,7 @@ void OnCommand(Event event) {
|
||||
|
||||
|
||||
if (CtrlShiftPress(SDLK_Q)) {
|
||||
Command_Eval(FetchLoadWord());
|
||||
Command_Open(FetchLoadWord(), "exec");
|
||||
} else if (CtrlPress(SDLK_Q)) {
|
||||
Command_Open(FetchLoadWord());
|
||||
if (active.view->fuzzy_search) {
|
||||
|
||||
@@ -57,7 +57,7 @@ Color.TitleBarText = GruvboxDark2
|
||||
Color.TitleBarBackground = GruvboxLight1
|
||||
Color.TitleBarActiveBackground = 0xfefefefe
|
||||
Color.TitleBarSelection = GruvboxLight3
|
||||
Color.ResizerBackground = GruvboxLight0Soft
|
||||
Color.ResizerBackground = GruvboxLight0Hard
|
||||
Color.ResizerOutline = GruvboxLight3
|
||||
Style = {}
|
||||
Style.WaitForEvents = 1
|
||||
@@ -303,11 +303,25 @@ function MatchGotoBuild(s, meta)
|
||||
return nil
|
||||
end
|
||||
|
||||
function MatchExec(s, meta)
|
||||
if meta ~= "exec" then
|
||||
return nil
|
||||
end
|
||||
|
||||
if c:match(".exe$") then
|
||||
return {kind = "exec_console", cmd = c, working_dir = GetMainDir()}
|
||||
end
|
||||
|
||||
Eval(s)
|
||||
return nil
|
||||
end
|
||||
|
||||
OnOpenMatchers = {
|
||||
MatchWindowsPath,
|
||||
MatchGitCommit,
|
||||
MatchURL,
|
||||
MatchGotoBuild,
|
||||
MatchExec,
|
||||
}
|
||||
|
||||
function OnOpen(path, meta)
|
||||
|
||||
@@ -55,7 +55,7 @@ Color ColorTitleBarText = GruvboxDark2;
|
||||
Color ColorTitleBarBackground = GruvboxLight1;
|
||||
Color ColorTitleBarActiveBackground = {0xfe, 0xfe, 0xfe, 0xfe};
|
||||
Color ColorTitleBarSelection = GruvboxLight3;
|
||||
Color ColorResizerBackground = GruvboxLight0Soft;
|
||||
Color ColorResizerBackground = GruvboxLight0Hard;
|
||||
Color ColorResizerOutline = GruvboxLight3;
|
||||
Int StyleWaitForEvents = 1;
|
||||
Int StyleDrawLineNumbers = 1;
|
||||
|
||||
@@ -74,7 +74,8 @@ void InitScratchBuffer() {
|
||||
|
||||
GCInfoBuffer = CreateBuffer(sys_allocator, GetUniqueBufferName(Command_GetBaseDir(), "gc"));
|
||||
EventBuffer = CreateBuffer(sys_allocator, GetUniqueBufferName(Command_GetBaseDir(), "events"));
|
||||
ScratchBuffer = CreateBuffer(sys_allocator, GetUniqueBufferName(Command_GetBaseDir(), "scratch"));
|
||||
ScratchBuffer = BufferOpenFile(GetUniqueBufferName(Command_GetBaseDir(), "scratch"));
|
||||
|
||||
EventBuffer->no_history = true;
|
||||
GCInfoBuffer->no_history = true;
|
||||
}
|
||||
@@ -381,15 +382,6 @@ String16 ToUnixString16(Allocator allocator, String string_) {
|
||||
return string;
|
||||
}
|
||||
|
||||
// This function as name suggests tries to open a buffer,
|
||||
// there is no name resolution here, path should already be resolved etc.
|
||||
//
|
||||
// 1. It tries to find an already open buffer
|
||||
// 2. Returns a buffer if the file doesn't exist (even if a directory doesn't exist)
|
||||
// - This is a worry for later time, also we want to handle weird names and so on
|
||||
// 3. If file exists we read it, convert to utf16, tabs to spaces etc.
|
||||
//
|
||||
// We don't really care about opening buffers that don't have proper paths
|
||||
Buffer *BufferOpenFile(String path) {
|
||||
Allocator sys_allocator = GetSystemAllocator();
|
||||
Scratch scratch;
|
||||
|
||||
@@ -151,6 +151,17 @@ inline bool operator!=(WindowID a, WindowID b) { return a.id != b.id; }
|
||||
inline bool operator!=(BufferID a, BufferID b) { return a.id != b.id; }
|
||||
inline bool operator!=(ViewID a, ViewID b) { return a.id != b.id; }
|
||||
|
||||
// This function as name suggests tries to open a buffer,
|
||||
// there is no name resolution here, path should already be resolved etc.
|
||||
//
|
||||
// 1. It tries to find an already open buffer
|
||||
// 2. Returns a buffer if the file doesn't exist (even if a directory doesn't exist)
|
||||
// - This is a worry for later time, also we want to handle weird names and so on
|
||||
// 3. If file exists we read it, convert to utf16, tabs to spaces etc.
|
||||
//
|
||||
// We don't really care about opening buffers that don't have proper paths
|
||||
Buffer *BufferOpenFile(String path);
|
||||
|
||||
#if DEBUG_BUILD
|
||||
#define IF_DEBUG(x) x
|
||||
#else
|
||||
|
||||
@@ -1,32 +1,41 @@
|
||||
- Changing window properties by changing the window name?
|
||||
- commands for scrolling: center, cursor_at_bottom_of_screen, cursor_at_top
|
||||
- organize commands and lua bindings somehow, it's kinda confusing right now, maybe group command->luacommand, the command name implies it also doubles as lua command?
|
||||
- Add metadata to Lua bindings so that we would get a better listing (function args?, what else?)
|
||||
- Kill buffer command (it should be marked for deletion and deleted at the end of frame!)
|
||||
- Delete directory/file on disk command
|
||||
- Check. Convert more commands to taking buffer instead of view
|
||||
- Check. Rewrite more commands to use already implemented commands?
|
||||
- Set window layout using project file
|
||||
- Split command
|
||||
- not needed but would be nice:
|
||||
- Query ids somehow
|
||||
- Open buffer using id
|
||||
- Set active window using id
|
||||
- Fix Ctrl+1 Ctrl+2 (choosing window)
|
||||
- Fix search, should have an anchor
|
||||
|
||||
- Command that will select a lua (block|function|line)? and eval
|
||||
- Use project file as working dir instead of scratch buffer path, separate project dir and project file
|
||||
|
||||
- Maybe Shift+Ctrl+Click sends a meta command of execute to Open(), it would allow to open exes
|
||||
- Enclose line (Ctrl + L)
|
||||
- Enclose most outer scope (but without the last chars, this would be for eval)
|
||||
- Enclose scope
|
||||
|
||||
- save all relevant buffers and build
|
||||
- maybe most of the bindings should be in lua, but actual code in C
|
||||
- maybe less code should be in lua ?? Lua code is very dodgey to change
|
||||
- LoadWord, EncloseWord configurable?
|
||||
- dump text editor state to file, restore state
|
||||
- help menu popup when for example in process buffer, on tile bar buffer and stuff like that
|
||||
- proper lister
|
||||
|
||||
- adding items to directory should create files on save - it should ask the user (syntax: dir/ | file)
|
||||
- ask user if he really wants to quit even though he has an unsaved buffer - popup window | we could just show ForceClose() in the titlebar
|
||||
- Find matches using grep, change things in that buffer then apply those changes to all items
|
||||
- group history entries so the you can rollback through multiple ones at once and not waste time on skipping whitespace trimming or deleting every character
|
||||
- Search and replace
|
||||
- some split selection commands
|
||||
- A lister which is going to show project without the full path and sorted by recency
|
||||
- word complete
|
||||
- Search all buffers in 10X style, incrementally searched results popping up on every key press (maybe we need coroutine library in C so this is easier?)
|
||||
- kill view - killing all views for buffer ejects buffer (maybe also introduce kill buffer)
|
||||
- ask if you want to create new file?
|
||||
- escapeing multiple cursor after ctrl + d should put the cursor where it was (probably will need to swap secondary and primary cursor for new cursor
|
||||
- draw indentation levels like in sublime (those lines) - we render chars one by one so seems relatively easy to figure out if whitespace belongs to beginning of line (make sure to add max value like 40 because of big files)
|
||||
- code sections, visual demarkation if beginning of line has a very specific text + goto next / goto prev section hotkey!
|
||||
@@ -49,13 +58,5 @@ backlog
|
||||
- optimize rendering - command buffer, and vertice buffer instead of vertice buffer with scissor
|
||||
- fix mouse cursor code, visual artifacts, fast cursor changing stuff
|
||||
|
||||
--------------
|
||||
buffer = make_buffer()
|
||||
buffer.append(list_files("src/basic"))
|
||||
activate_buffer
|
||||
--------------
|
||||
|
||||
|
||||
|
||||
|
||||
!!As little lua code as possible, but lua code should be powerful just in case of quick edits
|
||||
Reference in New Issue
Block a user