Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add table of contents to Gui/journal #1243

Merged
merged 27 commits into from
Aug 3, 2024

Conversation

wiktor-obrebski
Copy link
Contributor

@wiktor-obrebski wiktor-obrebski commented Jul 28, 2024

Description

screen

Add table of contents and undo/redo features to the gui/journal script.
Notable features:

  • adding line starting from # give 1-th level ToC header. ## and more give more indented ToC links
  • Ctrl+O toggle ToC
  • visible "Shifter" button to show/hide ToC
  • ToC panel can be resized by mouse
  • click in ToC entry scroll to given header in the text
  • CTRL+Z undo, CTRL+Y redo

Bugfixes:

  • 2846 numbers are not longer interpreted as cursor moves

TODO later

  • add buttons to insert new header of 1/2/3 indentation (to ToC panel?)
  • stop render text on resize, it is slow
  • consider hiding ToC panel (now panel without STYLE_FRAME can not be resized)

@myk002
Copy link
Member

myk002 commented Jul 28, 2024

Copying here from Discord:

You can give it a frame style that renders gui.CLEAR_PEN like this:

local INVISIBLE_FRAME = {
    frame_pen=gui.CLEAR_PEN,
    signature_pen=false,
}

Also, there should be hotkeys to jump to prev/next heading for the keyboard-only users

Hotkey buttons could be added to the bottom, underneath a horizontal widgets.Divider, until we get icons for them, at which time they can be moved to the top

The vertical widgets.Divider for the ToC can link into the bottom horizontal Divider if you use the same frame_style (gui.FRAME_THIN)

Copy link
Member

@myk002 myk002 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is awesome ; )

docs/gui/journal.rst Outdated Show resolved Hide resolved
gui/journal.lua Show resolved Hide resolved
gui/journal.lua Show resolved Hide resolved
Jump to previous/next section by ctrl+up/ctrl+down, working only
in beta 51.01+
@wiktor-obrebski
Copy link
Contributor Author

@myk002 there is a problem with A_MOVE_N_DOWN and other new test keys.
I added them, as we discussed, to control sections, but tests run on game version without beta yet (if I understand correctly), so the keys are not supported. So, in tests I get

error: ./hack/lua/gui.lua:65: Invalid keycode: A_MOVE_N_DOWN

And similar errors

@myk002
Copy link
Member

myk002 commented Aug 1, 2024

Notes from playtesting:

The initial empty screen looks stark and scary. I think we need to add some help text:

  1. In the main text area, add a short intro about what the tool is, and direct the player's attention to the ? button for further info. This text disappears as soon as there is user text
  2. In the ToC area, show information about how to add headers. This text disappears once there is a header to show

The help blurbs can be implemented as additional widgets.WrappedLabel widgets that overlap the regular text areas and whose visible properties are set to functions that detect when they should be shown.

Possible main area help text:

Welcome to gui/journal! You can use this tool to take notes, track progress on your plans,
or anything else! The text you write here is saved with your fort. Please click on the ? button
in the upper right corner to see more information, including a list of keyboard navigation
hotkeys.

Possible ToC help text:

Start a line with # symbols to create headers. Those headers will appear here, and you can
click on them to jump to them in the text. Click on the ? button in the upper right corner
for more details.

@myk002 myk002 merged commit 1b2988c into DFHack:master Aug 3, 2024
10 checks passed
@myk002
Copy link
Member

myk002 commented Aug 3, 2024

merged so people can start testing a bit. We can figure out the help text in a different PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants