Skip to content

Commit

Permalink
Added VIM_NORMAL mode and fixed <C-r> so that it doesn't refresh.
Browse files Browse the repository at this point in the history
  • Loading branch information
ardagnir committed Mar 14, 2014
1 parent e258242 commit 99f9903
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions pterosaur.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function update(){
if (pterosaurCleanupCheck !== options["fullVim"])
cleanupPterosaur();

if (!options["fullVim"] || modes.main !== modes.INSERT && modes.main !== modes.AUTOCOMPLETE) {
if (!options["fullVim"] || modes.main !== modes.INSERT && modes.main !== modes.AUTOCOMPLETE && modes.main !== modes.VIM_NORMAL) {
if(pterFocused && modes.main !== modes.EX)
{
cleanupForTextbox();
Expand All @@ -80,6 +80,11 @@ function update(){
let val = tmpfile.read();
let metadata = metaTmpfile.read().split('\n');
vimMode = metadata[0]
if (vimMode === "n" && modes.main == modes.INSERT)
modes.push(modes.VIM_NORMAL)

if (vimMode === "i" && modes.main == modes.VIM_NORMAL)
modes.pop()
if (textBox) {
textBox.value = val;

Expand Down Expand Up @@ -178,8 +183,6 @@ modes.INSERT.params.onKeyPress = function(eventList) {

if (/^<(?:.-)*(?:BS|Space|Return|Del|Tab|C-h|C-w|C-u|C-k|C-r)>$/.test(inputChar)) {
//Currently, this also refreshes. I need to disable that.
if (inputChar==="<C-r>")
io.system('printf "\x12" > /tmp/pterosaur_fifo');
if (inputChar==="<Space>")
io.system('printf " " > /tmp/pterosaur_fifo');
if (inputChar==="<BS>")
Expand Down Expand Up @@ -234,6 +237,21 @@ var pterosaurCleanupCheck = false;

options.add(["fullVim"], "Edit all text inputs using vim", "boolean", false);

modes.addMode("VIM_NORMAL", {
char: "N",
desription: "Vim normal mode",
bases: [modes.INSERT]
})

mappings.builtin.add(
[modes.INSERT, modes.VIM_NORMAL],
["<C-r>"],
"Override refresh and send <C-r> to vim.",
function(){
io.system('printf "\x12" > /tmp/pterosaur_fifo');
},
{noTransaction: true});

commands.add(["vim[do]"],
"Send command to vim",
function (args) {
Expand Down

0 comments on commit 99f9903

Please sign in to comment.