Skip to content

Add Shortcut for Moving Selected Lines Up and Down (Line Swapping) #953

Description

@yehiarasheed

Relevant sub-area for this feature?

PDE

Feature description

While investigating the codebase to fix issue #950, I stumbled upon some commented implementations of Keyboard Shortcuts in the old repository. This feature specifically involves allowing the user to move selected lines up and down the editor (essentially swapping lines) using the Alt + ↑ / ↓ shortcut for Windows/Linux Systems or ⌥ + ↑ / ↓ for macOS Systems. Currently, Processing 4 does not include a keyboard shortcut for moving selected lines up or down. This feature is available in older versions but has been omitted in the newer repo. Implementing this functionality can improve user productivity and align Processing 4 with commonly used IDE features.

Benefits

According to the Processing.org website:

On August 9th 2021, we celebrated the twentieth anniversary of the first Processing software release. Through this time, we’ve promoted software literacy, particularly within the visual arts, and visual literacy within technology. Initially created to serve as a software sketchbook and to teach programming fundamentals within a visual context, Processing has also evolved into a development tool for professionals.

In my opinion, if we are promoting software and visual literacy within technology and targeting professionals alike, it makes perfect sense to add Keyboard Shortcuts and be more inclusive of all groups. Whether it's a student in school still learning programming or someone working in a professional environment.

This helps us:

  • Align Processing 4 with industry-standard IDE behavior.
  • Improve user workflow by allowing faster navigation and editing of code.
  • Increase overall usability for those used to working with shortcuts as well as people who are still learning shortcuts.

Possible challenges

I am to investigate this issue further, but leaving the code in the legacy version commented gives me the hint that the previous implementation caused some errors (and I hope to be wrong), although I didn't find anything about it in previous issues or discussions. In all cases, I suggest rewriting the implementation to match the currently implemented Keyboard Shortcuts in the new Processing release to keep everything consistent.

Note

As of Now, I haven't seen any issues with my Draft Implementation of the feature. I will be testing it more intensively.

Additional context

Here is the current IntelliJ Implementation of this Keyboard Shortcut

20250305-1938-45.2301527.mp4

Here is a Draft of how the feature is supposed to look like in Processing

Processing.4.Move.Lines.Demo.mp4

References

Legacy implementation in the old processing repository here.

More specifically, the handleMoveLines(boolean moveUp) method as well as the method calls in the ActionListener.

Note

This feature may introduce additional Multi-Line features, the implementation of a Line Duplicate Keyboard Shortcut and so on..

Would you like to work on the issue?

Yes, I would like to work on this issue.


Activity

  1. SableRaf commented on Mar 6, 2025

    @SableRaf
    Collaborator

    Hi @yehiarasheed and thanks for investigating this! It could be useful to locate the commit(s) that removed this feature to understand why it was commented out.

    By the way, you should know that we want to move away from the current implementation of the code editor since it relies on the legacy dependency JEdit Syntax. Our long-term goal is to transition parts of the UI to Jetpack Compose Multiplatform, with the editor likely being the last component to be replaced, as it’s such a critical part of the PDE.

    In the meantime, making small quality-of-life improvements like this could be worthwhile, as long as they don’t introduce unwanted side effects and don't require significant work on legacy code that will eventually be removed.

    cc @Stefterv, who may have additional insights.

  2. yehiarasheed commented on Mar 6, 2025

    @yehiarasheed
    ContributorAuthor

    Hi @SableRaf, I actually took a look at the commits but didn't dig deep enough since the Editor.java file was previously moved and renamed. After taking a more thorough look, I found out that it was commented under the commit 9a9b3e9, with the message:

    remove extra items from the Edit menu--they are too power user for the PDE audience.

    I think that settles that the code implementation wasn't causing any unexpected behavior or bugs and it was just too advanced for its time. That being said, this shortcut is pretty standard now, so I think it’s a solid quality-of-life improvement.

    As for implementation, I totally get that the long-term plan is to move to Jetpack Compose Multiplatform. If that’s happening soon, it probably makes more sense to just add this feature there. But if that’s still a while away, I can go ahead and implement it in the current editor and refactor it later when the transition happens. Let me know what you think!

  3. Stefterv commented on Mar 7, 2025

    @Stefterv
    Member

    Hi @yehiarasheed feel free to open a pull request to add this functionality. I agree that it could be there but should not visible in the edit menu.

  4. added theissue type on Mar 7, 2025
  5. Joo283 commented on Mar 15, 2025

    @Joo283

    Hello, I’m interested in working on this issue.
    I have reviewed the description and the existing implementation. Before proceeding, I’d like to clarify a few things:

    Is there any specific reason why the previous implementation was commented out?
    Should the new implementation follow the same structure as other keyboard shortcuts in Processing 4?
    Are there any known issues or discussions related to this feature?
    I will start working on a draft solution and test it thoroughly. Let me know if there are any additional guidelines I should follow.

    Looking forward to your response

  6. yehiarasheed commented on Mar 16, 2025

    @yehiarasheed
    ContributorAuthor

    Hi @Joo283,

    Thanks for your interest in this issue! I’ve already worked on it and submitted a PR, which has been approved. You can check it here: (PR #964).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions