Giter Site home page Giter Site logo

Confusing editor behavior about hex.nvim HOT 5 OPEN

shmerl avatar shmerl commented on July 22, 2024
Confusing editor behavior

from hex.nvim.

Comments (5)

RaafatTurki avatar RaafatTurki commented on July 22, 2024 3

Turns out it's totally possible to control what char insert on each key press.
For instance the following prevents the s char from being inserted into the buffer:

vim.api.nvim_create_autocmd({ "InsertCharPre" }, {
  callback = function(ev)
    if (vim.v.char == "s") then
      vim.v.char = ''
    end
  end
})

However that doesn't include other content modification methods like replacing, pasting, inc, dec .. etc
Also there are 3rd party plugins that can modify the buffer.

I might implement just the char inserting snippet above tho

from hex.nvim.

RaafatTurki avatar RaafatTurki commented on July 22, 2024

Hmm, I understand

Yes rn you are allowed to type stuff other than 00 - FF which isn't ideal but afaik there isn't a "sane" way of preventing it.

The way it works is it dumps the bytes of a file into a buffer, you then can edit your "hex/bytes" are with just 00-FF values and upon saving it would reconstruct the file out of the buffer.

from hex.nvim.

shmerl avatar shmerl commented on July 22, 2024

What happens if you put something else there besides 00-FF though? It just feeds that to xxd and it depends on how it handles it?

from hex.nvim.

shmerl avatar shmerl commented on July 22, 2024

That might be very suboptimal, but is there a way to put a hook on any key input and if it's within the hex plane, it can filter what input is allowed.

Something like this may be?

from hex.nvim.

shmerl avatar shmerl commented on July 22, 2024

Yeah, that sounds like it could improve things somewhat! Like you can check for the allowed range of characters for example.

from hex.nvim.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.