Comments (7)
Hey, I have set up this project on my local machine as required.
Screenshot:
Can I be assigned this issue?
from diffcessible.
Yes! You are now assigned this issue.
Do let us know when you are blocked and need assistance on this one!
from diffcessible.
@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.
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.
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.
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 withLwd.peek
and modify withLwd.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 thelet$
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.
@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)
- Status bar HOT 1
- Display current operation in status bar HOT 5
- Add dependencies to the `dune-project` file.
- Use keyboard arrows for scrolling HOT 9
- Bind `j` and `k` to scrolling HOT 4
- Compute and display number of added and removed lines in status bar HOT 7
- Compute and display number of hunks in the status bar. HOT 11
- Navigation between hunks HOT 12
- Outreachy Summer 2024: An accessible diff viewer HOT 9
- A more representative example file HOT 3
- Add CI testing using Github Actions HOT 6
- example.diff do not show a file with several hunks HOT 2
- Colorize addition and removal summary
- Horizontal scrolling HOT 11
- Add keybinding to scroll to the top HOT 5
- Show line numbers in side-by-side diffs HOT 1
- Show line numbers in diffs HOT 2
- Outreachy Application: How to provide a timeline for the project HOT 5
- Test for the interface HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from diffcessible.