summaryrefslogtreecommitdiffstats
path: root/src/ex_cmds.c
AgeCommit message (Expand)Author
2024-05-20patch 9.1.0426: too many strlen() calls in search.cv9.1.0426John Marriott
2024-05-19patch 9.1.0420: :browse oldfiles prompts even with single entryv9.1.0420Christian Brabandt
2024-03-31patch 9.1.0231: Filetype may be undetected when SwapExists sets ft in other bufv9.1.0231zeertzjq
2024-03-21patch 9.1.0195: memleak with ex_drop, NULL dereferencev9.1.0195Christian Brabandt
2024-03-20patch 9.1.0192: drop: don't rewind when editing the same filev9.1.0192Christian Brabandt
2024-03-12patch 9.1.0172: More code can use ml_get_buf_len() instead of STRLEN()v9.1.0172zeertzjq
2024-03-03patch 9.1.0147: Cannot keep a buffer focused in a windowv9.1.0147Colin Kennedy
2024-02-09patch 9.1.0089: qsort() comparison functions should be transitivev9.1.0089Christian Brabandt
2024-01-23patch 9.1.0047: issues with temp curwin/buf while cmdwin is openv9.1.0047Sean Dewar
2024-01-23patch 9.1.0046: :drop does not re-use empty bufferv9.1.0046Rocco Mao
2024-01-04patch 9.1.0006: is*() and to*() function may be unsafev9.1.0006Keith Thompson
2023-12-19patch 9.0.2180: POSIX function name in exarg causes issuesv9.0.2180Zoltan Arpadffy
2023-12-01patch 9.0.2143: [security]: buffer-overflow in ex_substitutev9.0.2143Christian Brabandt
2023-11-22patch 9.0.2121: [security]: use-after-free in ex_substitutev9.0.2121Christian Brabandt
2023-11-16patch 9.0.2108: [security]: overflow with count for :s commandv9.0.2108Christian Brabandt
2023-09-09patch 9.0.1886: Various Typosv9.0.1886Christian Brabandt
2023-09-05patch 9.0.1873: [security] heap-buffer-overflow in vim_regsub_bothv9.0.1873Christian Brabandt
2023-09-02patch 9.0.1849: CI error on different signedness in ex_cmds.cv9.0.1849Christian Brabandt
2023-09-02patch 9.0.1848: [security] buffer-overflow in vim_regsub_both()v9.0.1848Christian Brabandt
2023-09-02patch 9.0.1841: style: trailing whitespace in ex_cmds.cv9.0.1841Christian Brabandt
2023-09-02patch 9.0.1840: [security] use-after-free in do_ecmdv9.0.1840Christian Brabandt
2023-05-20patch 9.0.1571: RedrawingDisabled not used consistentlyv9.0.1571Bram Moolenaar
2023-05-10patch 9.0.1538: :wqall does not trigger ExitPrev9.0.1538Bram Moolenaar
2023-04-22patch 9.0.1479: small source file problems; outdated list of distrib. filesv9.0.1479Bram Moolenaar
2023-03-04patch 9.0.1380: CTRL-X on 2**64 subtracts twov9.0.1380Bram Moolenaar
2023-02-20patch 9.0.1330: handling new value of an option has a long "else if" chainv9.0.1330Yegappan Lakshmanan
2023-01-22patch 9.0.1234: the code style has to be checked manuallyv9.0.1234Bram Moolenaar
2023-01-09patch 9.0.1166: code is indented more than necessaryv9.0.1166Yegappan Lakshmanan
2022-12-30patch 9.0.1115: code is indented more than neededv9.0.1115Yegappan Lakshmanan
2022-12-23patch 9.0.1092: search error message doesn't show used patternv9.0.1092Rob Pilling
2022-11-12patch 9.0.0864: crash when using "!!" without a previous shell commandv9.0.0864Bram Moolenaar
2022-11-08patch 9.0.0845: shell command with just space gives strange errorv9.0.0845shane.xb.qian
2022-10-29patch 9.0.0820: memory leak with empty shell commandv9.0.0820Bram Moolenaar
2022-10-22patch 9.0.0817v9.0.0817v9.0.0816Bram Moolenaar
2022-10-22patch 9.0.0815v9.0.0815Martin Tournoij
2022-10-17patch 9.0.0785: memory leak with empty shell commandv9.0.0785Bram Moolenaar
2022-10-17patch 9.0.0783: ":!" doesn't do anything but does update the previous commandv9.0.0783Bram Moolenaar
2022-10-14patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'v9.0.0751Bram Moolenaar
2022-10-04patch 9.0.0657: too many #ifdefsv9.0.0657Martin Tournoij
2022-10-03patch 9.0.0648: when using powershell input redirection does not workv9.0.0648Yegappan Lakshmanan
2022-09-19patch 9.0.0506: line number argument for :badd does not workv9.0.0506Bram Moolenaar
2022-09-17patch 9.0.0491: no good reason to build without the float featurev9.0.0491Bram Moolenaar
2022-09-14patch 9.0.0467: build failurev9.0.0467Bram Moolenaar
2022-09-13patch 9.0.0457: substitute prompt does not highlight an empty matchv9.0.0457Bram Moolenaar
2022-08-31patch 9.0.0340: the 'cmdheight' zero support causes too much troublev9.0.0340Bram Moolenaar
2022-08-30patch 9.0.0332: overwrite check may block BufWriteCmdv9.0.0332zeertzjq
2022-08-29patch 9.0.0318: clearing screen causes flickerv9.0.0318Bram Moolenaar
2022-08-29patch 9.0.0315: shell command is displayed in message windowv9.0.0315Bram Moolenaar
2022-08-25patch 9.0.0263: too many #ifdefsv9.0.0263Bram Moolenaar
2022-08-14patch 9.0.0206: redraw flags are not named specificallyv9.0.0206Bram Moolenaar
"n">conf.verbs { match Verb::create_external( &verb_conf.invocation, verb_conf.shortcut.clone(), verb_conf.execution.clone(), verb_conf.description.clone(), verb_conf.from_shell.unwrap_or(false), verb_conf.leave_broot.unwrap_or(true), verb_conf.confirm.unwrap_or(false), ) { Ok(v) => { self.verbs.push(v); } Err(e) => { eprintln!("Verb error: {:?}", e); } } } self.add_builtin( "back", None, "revert to the previous state (mapped to `<esc>`)", ); self.verbs.push( Verb::create_external( "cd", None, // no real need for a shortcut as it's mapped to alt-enter "cd {directory}".to_string(), Some("change directory and quit (mapped to `<alt><enter>`)".to_string()), true, // needs to be launched from the parent shell true, // leaves broot false, ) .unwrap(), ); self.verbs.push( Verb::create_external( "cp {newpath}", None, "/bin/cp -r {file} {parent}/{newpath}".to_string(), None, false, false, false, ) .unwrap(), ); self.add_builtin( "focus", Some("goto".to_string()), "display the directory (mapped to `<enter>` in tree)", ); self.add_builtin("help", Some("?".to_string()), "display broot's help"); self.verbs.push( Verb::create_external( "mkdir {subpath}", Some("md".to_string()), "/bin/mkdir -p {directory}/{subpath}".to_string(), None, false, false, // doesn't leave broot false, ) .unwrap(), ); self.verbs.push( Verb::create_external( "mv {newpath}", None, "/bin/mv {file} {parent}/{newpath}".to_string(), None, false, false, // doesn't leave broot false, ) .unwrap(), ); self.add_builtin( "open", None, "open file or directory according to OS settings (quit broot)", ); self.add_builtin("parent", None, "move to the parent directory"); self.add_builtin( "print_path", Some("pp".to_string()), "print path and leaves broot", ); self.add_builtin( "print_tree", Some("pt".to_string()), "print tree and leaves broot", ); self.add_builtin("quit", Some("q".to_string()), "quit the application"); self.verbs.push( Verb::create_external( "rm", None, "/bin/rm -rf {file}".to_string(), None, false, false, // doesn't leave broot false, ) .unwrap(), ); self.add_builtin( "toggle_dates", Some("dates".to_string()), "toggle showing last modified dates", ); self.add_builtin( "toggle_files", Some("files".to_string()), "toggle showing files (or just folders)", ); self.add_builtin( "toggle_git_ignore", Some("gi".to_string()), "toggle use of .gitignore", ); self.add_builtin( "toggle_hidden", Some("h".to_string()), "toggle showing hidden files", ); if permissions::supported() { self.add_builtin( "toggle_perm", Some("perm".to_string()), "toggle showing file permissions", ); } self.add_builtin( "toggle_sizes", Some("sizes".to_string()), "toggle showing sizes", ); self.add_builtin( "toggle_trim_root", Some("t".to_string()), "toggle removing nodes at first level too (default)", ); } pub fn search(&self, prefix: &str) -> PrefixSearchResult<&Verb> { let mut found_index = 0; let mut nb_found = 0; for (index, verb) in self.verbs.iter().enumerate() { if let Some(shortcut) = &verb.shortcut { if shortcut.starts_with(prefix) { if shortcut == prefix { return PrefixSearchResult::Match(&verb); } found_index = index; nb_found += 1; continue; } } if verb.invocation.key.starts_with(prefix) { if verb.invocation.key == prefix { return PrefixSearchResult::Match(&verb); } found_index = index; nb_found += 1; } } match nb_found { 0 => PrefixSearchResult::NoMatch, 1 => PrefixSearchResult::Match(&self.verbs[found_index]), _ => PrefixSearchResult::TooManyMatches, } } // return the index of the verb having the long key. This function is meant // for internal access when it's sure it can't failed (i.e. for a builtin) // It looks for verbs by key, starting from the builtins, to // ensure it hasn't been overriden. pub fn index_of(&self, key: &str) -> usize { for i in 0..self.verbs.len() { if self.verbs[i].invocation.key == key { return i; } } panic!("invalid verb search"); } }