Giter Site home page Giter Site logo

Comments (6)

MultiMUD avatar MultiMUD commented on June 11, 2024 4

v0.10.0 will include this:

(require '[lanterna.terminal :as t] 
               '[lanterna.api :as api])
(let [term (-> (t/get-terminal :swing) api/start) 
        stroke (api/get-stroke term)] 
  (api/stop term) 
  stroke)
;; hitting alt-a (on BSD) => {:key \a, :ctrl false, :alt true, :shift false}

from clojure-lanterna.

heyestom avatar heyestom commented on June 11, 2024 1

+1 This would be very useful.
There is #18 which provides behaviour similar to what is being asked for. :)

from clojure-lanterna.

fromheten avatar fromheten commented on June 11, 2024

@MultiMUD Will the get-key function then sometimes return a string and sometimes a map?

If you want to keep backwards compatibility (always a good idea, and a proud tradition in Clojure-land), a simple way could be to just add functions get-key-with-modifier & get-key-with-modifier-blocking which always return a map like {:key \a, :ctrl false, :alt true, :shift false}.

Please keep my suggestion in mind, and thanks for the nice library!

from clojure-lanterna.

MultiMUD avatar MultiMUD commented on June 11, 2024

@fromheten backwards compatibility was a requirement when handing over the repository & project from @sjl. To achieve this, there will be a split in API between 0.9.7 (current and last release by @sjl) and 0.10.0: The terminal and screen API will remain unchanged, maybe even a bit extended, with the mindset that this is the "low level", stable API. On top of this there will be a (protocol driven) generic API for all things drawing in lanterna3, terminals, screens and textgraphics. This allows experimentation for a more clojurey API on a higher layer, while current code will remain to function as expected with an updated clojure-lanterna. The only thing that changes from the low-level API is the return value (for any side-effecting fn this will return the context object (the first argument to the functions, a terminal or screen) as to permit (->) chaining of the fns. Check out the lanterna3 branch for a mid-development state snapshot.

So to directly answer your question: get-key returns a keycode constant now, and it will continue doing so. To get the map version, use get-stroke (a new fn) from either the low-level, or the API namespace.

from clojure-lanterna.

fromheten avatar fromheten commented on June 11, 2024

@MultiMUD all right, if I understand you correctly it will be backwards compatible. Cheers

from clojure-lanterna.

MultiMUD avatar MultiMUD commented on June 11, 2024

Indeed. I'd consider it a bug if it isn't (save for the one-offs that make programming and design so beautiful :) )

from clojure-lanterna.

Related Issues (10)

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.