Giter Site home page Giter Site logo

Create a help panel about diffcessible HOT 7 CLOSED

panglesd avatar panglesd commented on August 22, 2024
Create a help panel

from diffcessible.

Comments (7)

Siddhi-agg avatar Siddhi-agg commented on August 22, 2024

Hey, I have set up this project on my local machine as required.
Screenshot:
Screenshot 2024-03-06 201645
Can I be assigned this issue?

from diffcessible.

panglesd avatar panglesd commented on August 22, 2024

Yes! You are now assigned this issue.

Do let us know when you are blocked and need assistance on this one!

from diffcessible.

Siddhi-agg avatar Siddhi-agg commented on August 22, 2024

@panglesd I have read and got an understanding of the code in the /bin and /lib directory. I am a bit unclear about what the help panel should include. Should it just have the explanation of the keyboard key functions like n, p or should it also contain the information about the diffcessible command & its arguments?
Can you please elaborate on that?

from diffcessible.

panglesd avatar panglesd commented on August 22, 2024

Sure!

The help panel will only contain a small explanation of the layout of what you can find on the screen, and a list of key-bindings.

Currently, the keybindings are only n, p, q and soon h, so it might feel a little bit empty. However, we plan to have UpArrow/DownArrow and j, k to scroll, some key to alternate between "side-by-side" diff and normal diff, maybe a way to navigate hunks (instead of operations...).

Having the help panel already implemented will simplify the addition of help for those new key-bindings!

from diffcessible.

Siddhi-agg avatar Siddhi-agg commented on August 22, 2024

I have tried implementing a logic for a toggle help panel which goes like:

let view (patches : Patch.t list) =
let z_patches : 'a Zipper.t Lwd.var =
match Zipper.zipper_of_list patches with
| Some z -> Lwd.var z
| None -> failwith "zipper_of_list: empty list"
in
let help_panel = Ui.vcat
[
W.string "h: This key can be used to toggle the help panel";
W.string "q: This key can be used to quit the diffcessible viewer";
W.string "n: This key can be used to move to the next operation, if present";
W.string "p: This key can be used to move to the previous operation, if present" ;
] in
let help_visible = Lwd.var false in
if Lwd.peek help_visible then W.vbox[
Lwd.pure @@ help_panel;
Lwd.pure
@@ Ui.keyboard_area
(function
| ASCII 'q', [] -> Lwd.set quit true; Handled
| ASCII 'h', [] -> Lwd.set help_visible false; Handled
| _ -> `Unhandled)
(W.string "Type 'q' to quit, 'h' to exit the help panel");

]else
W.vbox
[
operation_info z_patches;
current_operation z_patches;
W.scrollbox @@ current_hunks z_patches;

After testing it, I found the toggling function was not working. Can you suggest me why that may be happening?

from diffcessible.

panglesd avatar panglesd commented on August 22, 2024

It's a good start! But there are some small issues.

Let me explain again some of concepts of Lwd:

  • Lwd.var is a variable: it contains some data (that you can see with Lwd.peek and modify with Lwd.set)
  • The 'a Lwd.t type is the type of a 'a that might change over time
  • The Lwd.get function allows you to turn an lwd variable into a value that might change over time! (It changes when the value of the variable change)
  • The Lwd.bind allows to take values that changes over time, and create a new value that changes time, with a regular function. This is mostly used through the let$ syntax.
  • A UI element that changes over time will have the changes reflected in the terminal. So the idea is to have a few Lwd variables, and build the UI from them. Whenever they change, the changes in the UI will be reflected in the terminal.

Some additional (arguably not easy to read) documentation for lwd is available in its homepage.

Hope this helps! Let me know if you need more assistance. But since you already have some code written, it would be better to open a PR, even unfinished: that's much better to read and comment the code than a screenshot or copy-pasted unsyntaxhighlighted code...

from diffcessible.

Siddhi-agg avatar Siddhi-agg commented on August 22, 2024

@panglesd Thanks for explaining these concepts. I understood why even after pressing h key, the help panel isn't being displayed and now I am working on implementing how to use Lwd.get to check if the help panel should be visible.
I am currently reading the documentation for Lwd and also watching some video tutorials for getting a better understanding of the code.

from diffcessible.

Related Issues (20)

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.