-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
/ to redefine glob at runtime #40
Comments
This seems really cool, I'm game to work on this if no one else is. Really like the feature list so far, but I think an interesting addition would be to take the vim roots and have, if the provided file is in |
I don't see that anybody else is assigned to the issue. |
@NickHackman #48 |
@gurgalex Easy solution would be just to use relative paths to prevent multiple matches, but man it would be way cooler if we used 'n', or 'N' (backwards) like in vim to move between the multiple matches. |
Having both would be nice. redefine glob and searching for matches (without redefining global glob) I really did want a config file or something to change default keybindings for this case (user prefs). Hmm, can yo make an issue detailing the proposed feature (search) and a good keyboard default for it. Unsure if (Shift + /) (?) could be a good one. |
I'll write up a spec for the issue you describe. As for keybindings, perhaps slash for what you describe would be best. Then this feature could use |
I think this is what we're both thinking. issue I described: configurable keyboard shortcuts via config Glob redefine: search for image in current glob: |
@Davejkane After spending a good amount of time learning sdl2 more closely, I hit a roadblock with implementing and the potential solution I have, I think, should need approval. So in order to properly get the user input I need to be able to drive the event loop as seen here more than one event loop can't exist and would probably be catastrophic if it could. Note: when I say As of right now I'm just following suit of Potential solution: go towards a modal flow of command Changes:
pub enum Mode {
Normal, // [default] (current run)
Command,
// additional modes would be an easy addition
Exit,
} In the current situation Exit would only be called from normal. This would allow the ownership of event loops to be changed. Allowing user input to be gathered for #40, #53, maybe even an add image/glob feature as well (future) and a further progression towards a Vim ideal.
I think this is a large enough change of how the app functions that I don't feel okay just opening a pull request with this and drop the bomb on you and @gurgalex without expressing my intentions. Extra Features
Future IdeasAs mentioned above add would be a good addition in the future, so maybe a change to a more general input like
or
Keybinding Modifications to Current IssueThis makes me also think changing the current keybindings for search/change_glob to something that follows the above
or
I could also see using the traditional |
@NickHackman pub struct Action {
//~snip~//
/// Put number on Screen for Numeric operations
NumericOp(u32),
// ~snip~//
}
/// The state of the Input processor. Determines
/// Different actions are taken on the same key depending on the StateEntry
pub enum StateEntry {
/// Process input normally
Normal,
/// Process when expecting numeric commands
Numeric,
}
pub fn event_action(state: &mut State, event: &Event) -> Action {
//~snip~//
match event {
//~snip~//
Event::KeyDown {
keycode: Some(k),
keymod: m,
..
} => match (k, m) {
(_, &Mod::NOMOD) => match k {
// NOMOD are numbers on numpad
Num1 | Num2 | Num3 | Num4 | Num5 | Num6 | Num7 | Num8 | Num9 | Num0 | Kp0 | Kp1
| Kp2 | Kp3 | Kp4 | Kp5 | Kp6 | Kp7 | Kp8 | Kp9 => {state.input_state = StateEntry::Numeric; process_numeric(state, event)},
//~snip~//
}
pub struct State {
/// render_infobar determines whether or not the info bar should be rendered.
pub render_infobar: bool,
/// render_help determines whether or not the help info should be rendered.
pub render_help: bool,
/// Should the image shown be shown in actual pixel dimensions
pub actual_size: bool,
/// Tracks fullscreen state of app.
pub fullscreen: bool,
/// Input Event processing state
pub input_state: StateEntry,
/// Unprocessed text
unprocessed_input: String,
} |
Maybe a name like |
Found a great article on state machines for some ideas. |
Yeah that's good abbreviated to Oh, also on #48 probably a good idea to follow vim and display in the far right of the infobar all keys pressed. Really like how that's coming along 👍 |
Oh, didn't know vim even had that. |
Thought Looks like lowercase is common for vim commands. Along with abbreviations (and shortened names)
So, |
|
Sweet, newglob/ng it is I think |
Only having the top level Mode (first upon program open) capture KeyDown
events seems useful.
Capturing TextInput events and ignoring most keypress events will be useful
it seems for states where we are not in the program's main input handler
state.
Plus Capital letters are one event.
https://love2d.org/forums/viewtopic.php?t=81729
…On Thu, May 16, 2019, 20:19 Nick Hackman ***@***.***> wrote:
Sweet, newglob/ng it is
I think Mode makes the most sense in this context
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#40?email_source=notifications&email_token=AG5ANRCZW4ETND63Z6PAGOTPVYB2PA5CNFSM4HMKN2GKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVTOWQA#issuecomment-493284160>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AG5ANRDOCKMDATBGLZPMIYTPVYB2PANCNFSM4HMKN2GA>
.
|
Not sure I understand what you mean, if you're referring to normal (default) mode it for the most part captures only KeyDown events. Yeah, as of right now I'm only capturing Escape/Return/Enter/Return2, everything else is being captured by TextInput, on second thought it should also be handling resizing where we need to rerender. |
Mostly a heads up that typing "/" generates a KeyDown, TextInput and a
KeyUp event.
…On Fri, May 17, 2019, 01:03 Nick Hackman ***@***.***> wrote:
Only having the top level Mode (first upon program open) capture KeyDown
events seems useful.
Not sure I understand what you mean, if you're referring to normal
(default) mode it for the most part captures only KeyDown events.
Yeah, as of right now I'm only capturing Escape/Return/Enter/Return2,
everything else is being captured by TextInput, on second thought it should
also be handling resizing where we need to rerender.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#40?email_source=notifications&email_token=AG5ANREQ4PKZMS76EQS3LVLPVZDCXA5CNFSM4HMKN2GKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVT2JOQ#issuecomment-493331642>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AG5ANRGWQWOLOO44FEGURI3PVZDCXANCNFSM4HMKN2GA>
.
|
This all seems very cool, and pretty interesting. I have no issue with the way you're solving it. |
Goal
Add an extra handle for the
/
(because it's used for search in vim) to allow redefining the glob at runtime.Implementation
This will require the following to be taken into consideration:
/
key to start taking keyboard input as a string.enter
orreturn
key to indicate end of input.images
pathsAs for the text input, we will probably need to use https://rust-sdl2.github.io/rust-sdl2/sdl2/keyboard/struct.TextInputUtil.html.
Although this tutorial is in C, it appears very relevant. https://wiki.libsdl.org/Tutorials/TextInput
This video also contains some caveats about backspace. https://www.youtube.com/watch?v=m2doh3Li65c
The text was updated successfully, but these errors were encountered: