Skip to content

Add features on comments view and navigation between PDFs with left/right arrow keys. - #220

Open
nathan-ed wants to merge 15 commits into
ClementGre:masterfrom
nathan-ed:claude/fix-add-comments-t-view-011CUpKvAEL94FCWhM1SoZfC
Open

nathan-ed wants to merge 15 commits into
ClementGre:masterfrom
nathan-ed:claude/fix-add-comments-t-view-011CUpKvAEL94FCWhM1SoZfC

Conversation

@nathan-ed

Copy link
Copy Markdown

Disclaimer

Everything was implemented using Claude Code Web and verified by the user.

Summary

Added autocomplete dropdown and insert comment when hitting ENTER to the T view (text comments) and PDF navigation improvements with left/right arrows.

Autocomplete Dropdown for Text Comments

  • Display matching remarks from favorites/lasts/onFile sections as user types
  • Navigate dropdown with UP/DOWN arrow keys
  • Insert selected remark with ENTER key or mouse click
  • ESC key removes focus from text area to enable app-level navigation
  • Preserves full text formatting (font, size, color, bold, italic)
  • Maintains existing left panel highlighting behavior

Technical implementation:

  • Custom ListView cell factory with Label graphics for proper rendering
  • Dual event filters (KEY_PRESSED and KEY_TYPED) to handle Enter key
  • Dynamic text color based on selection state (white when selected, black otherwise)
  • Popup with autoHide behavior positioned below text area
  • List height: 250px preferred, 400px max for full visibility

LEFT/RIGHT Arrow Navigation Between PDFs

  • LEFT arrow: Navigate to previous PDF in list
  • RIGHT arrow: Navigate to next PDF in list
  • Preserves page number across PDFs (scrolls to top of same page in next PDF)
  • Uses lazy keyboard shortcuts (lower priority, safe UI elements only)

Technical implementation:

  • Added forceScrollToPage field to MainScreen for page targeting
  • Pass resetScrollValue=true to openFile() to prevent Edition scroll restoration
  • 500ms delay ensures layout operations (showPages, loadEdition, updatePaneDimensions) complete
  • Uses scrollToPage() method for reliable scroll positioning

Known limitation: Page preservation only works reliably when at the top of a page. When scrolled within a page, navigation may jump to the next page due to viewport detection behavior of getFirstTopVisiblePage().

Files modified:

  • TextTab.java: Autocomplete dropdown functionality
  • KeyboardShortcuts.java: LEFT/RIGHT arrow handlers for PDF navigation
  • FileTab.java: loadPreviousFilePreservePage() and loadNextFilePreservePage()
  • MainScreen.java: Page targeting system with forceScrollToPage

## Autocomplete Dropdown for Text Comments
- Display matching remarks from favorites/lasts/onFile sections as user types
- Navigate dropdown with UP/DOWN arrow keys
- Insert selected remark with ENTER key or mouse click
- ESC key removes focus from text area to enable app-level navigation
- Preserves full text formatting (font, size, color, bold, italic)
- Maintains existing left panel highlighting behavior

Technical implementation:
- Custom ListView cell factory with Label graphics for proper rendering
- Dual event filters (KEY_PRESSED and KEY_TYPED) to handle Enter key
- Dynamic text color based on selection state (white when selected, black otherwise)
- Popup with autoHide behavior positioned below text area
- List height: 250px preferred, 400px max for full visibility

## LEFT/RIGHT Arrow Navigation Between PDFs
- LEFT arrow: Navigate to previous PDF in list
- RIGHT arrow: Navigate to next PDF in list
- Preserves page number across PDFs (scrolls to top of same page in next PDF)
- Uses lazy keyboard shortcuts (lower priority, safe UI elements only)

Technical implementation:
- Added forceScrollToPage field to MainScreen for page targeting
- Pass resetScrollValue=true to openFile() to prevent Edition scroll restoration
- 500ms delay ensures layout operations (showPages, loadEdition, updatePaneDimensions) complete
- Uses scrollToPage() method for reliable scroll positioning

Known limitation: Page preservation only works reliably when at the top of a page.
When scrolled within a page, navigation may jump to the next page due to viewport
detection behavior of getFirstTopVisiblePage().

Files modified:
- TextTab.java: Autocomplete dropdown functionality
- KeyboardShortcuts.java: LEFT/RIGHT arrow handlers for PDF navigation
- FileTab.java: loadPreviousFilePreservePage() and loadNextFilePreservePage()
- MainScreen.java: Page targeting system with forceScrollToPage
@ClementGre

Copy link
Copy Markdown
Owner

Thank you for contributing to PDF4Teachers. Here is a review of your MR :

  • There was already a mechanism to insert matching remarks from favorites/lasts/onFile sections as user types, and navigating with UP/DOWN arrow keys. It is not a dropdown, but a highlight of matching elements in the list, navigable with arrows. The dropdown you developed is then a redundant feature that allows the user to see more easily the matching elements, but that goes over the other elements of the sidebar, possibly reducing the user experience. What do you think about it? Also, would there be a way to use a ListView from JMetro for not having to customize the theme manually?
  • About the navigation between PDFs:
    • You edited the LEFT/RIGHT shortcut, but not the SHORTCUT_DOWN + ALT_DOWN + LEFT/RIGHT. Is this a choice, why ? I think it is interesting to use two different shortcuts for different behaviors, but it can be a lot for users, and it might be better to use the shortcut with SHORTCUT_DOWN + ALT_DOWN for this feature. We should also add AutoToolTips (see AutoTipsManager.java) and edit the documentation (I can do this myself later).
    • To fix your "Known limitation": you could remove the page number indirection and work only with the scroll value (0-1), or the y shift position. Anyway, a teacher using this feature will use it only on documents of the same size (hence the scroll value), or at least on documents of same page size (hence the y shift position).
    • About "Uses scrollToPage()" : can you instead use scrollByTranslateY disabling the animation, or even updatePaneDimensions if using scroll value ? This should allow you to remove the 500ms delay, removing the scrolling animation on switching to the next document.

nathan-ed and others added 14 commits June 1, 2026 07:55
Fixing the postinst script

(cherry picked from commit b016f06)
Remark saving (favorites/lasts/lists):
- Snapshot config data on the FX thread, write it on the saver thread
- Atomic writes (tmp + move), never write an older snapshot over a newer one
- No save before the file is loaded; back up unreadable files as .bak
- Save on color/font/width/uses changes and list save/delete

Shortcuts:
- One file switch per key press (holding a key no longer opens many files)
- Alt+PageUp/PageDown to switch files keeping the page/exercise
  (Ctrl+Alt+arrows are taken by most Linux desktops)
- Alt+Up/Down selects the previous/next exercise in exercise mode
- Left/Right move between pages again in grid view and edit pages mode
- Target page passed to openFile instead of a leaking mutable field
- ESC in the text area gives the focus back to the document

Page caching:
- Prefetched pages no longer keep the loading spinner
- A visible page queued as prefetch is moved to the front of the queue
- Pending renders of a page are merged; stale renders dropped on page jumps
- Neighbor files preload cancels outdated work, next file first,
  also when navigating without exercise mode
- Edition cache returns deep copies and is invalidated by simpleSave

Other:
- Enter inserts a new line unless a suggestion was picked with Up/Down;
  suggestions are deduplicated; debug prints removed
- Exercise pages keyed by grade name and stored per evaluation, with
  migration of the old Q1/Q2 mapping; exercise mode is persisted
- PNF: one undo step, blank text boxes are not taken as table rows
- New UI strings translated (en, fr)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each evaluation (identified by its exercise names) has a catalog of
comments linked to a sub-grade, with signed points. Placing one on a
copy shows "Comment (−0.5)" and computes the sub-grade from its max
(or from 0) plus the points of its comments; a typed value still wins.

- Grades tab panel: list filtered by exercise, click then click on the
  page to place (Shift keeps it armed), keys 1-9, page context submenu
- Per-copy edits (text or points) are kept when the entry is updated;
  reset, save as new entry, or use this version for all copies
- Entry changes are pushed to the other open copies with the same grade
  scale after a preview of the grade changes
- Search window to find the copies having a comment
- Stored in the texts section of edit files, readable as plain texts by
  older versions; catalogs in scoredcomments.yml

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cale

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ts, marks and Moodle export

- Store the data of an evaluation in a hidden .pdf4teachers folder next to its copies:
  comments by exercise, scored comments, notes and their screenshots. Existing notes and
  scored comments are migrated when their folder is opened.
- Texts tab: "This evaluation" section listing the comments written on the copies, grouped
  by exercise (found from where each comment is placed), with move/remove actions.
- "Where is it written?": page previews of every copy using a comment, across evaluations,
  zoomable around the comment; a click opens the copy at that page.
- Notes tab: personal notes and screenshots of a region of a copy (Ctrl+Shift+N / Ctrl+Shift+S),
  linked to their copy, page and exercise.
- Grading panel: buttons to jump to the page of each exercise (Alt+1..9).
- Formulas in texts with $...$ ($$...$$ still read): text keeps its font and wraps, formulas
  rendered inline, identical on screen and in the export. Wrapping, growing text field with
  preview, formula toggle and symbol buttons. The inverted default input mode is removed.
- Marks computed from the grades, and Moodle feedback export.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ws and review

- Grading panel "Methods & mistakes" card for the exercise being graded: chips to add or
  remove a method or a mistake on the copy, inline creation, rename, kind change, delete.
- # (or Ctrl+Shift+M) opens a picker at the mouse: search or create, Enter applies it at
  the spot under the mouse, Tab switches between method and mistake.
- Class overview: copies, share and average points of the exercise for each tag, and the
  copies without method.
- Previews of all the copies of a tag (or without method), zoomable around the spot, with
  the points of each copy; wider previews when zoomed in.
- Review mode: previous/next copy only goes through the copies of a tag, opened at the
  tagged spot, with a banner to step through or stop.
- Stored in the evaluation folder (.pdf4teachers/tags.yml), never written on the copies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants