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

Request to generate initial code on project creation #898

Open
nagesh007 opened this issue Dec 26, 2024 · 11 comments
Open

Request to generate initial code on project creation #898

nagesh007 opened this issue Dec 26, 2024 · 11 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed pde Processing Development Environment

Comments

@nagesh007
Copy link

Relevant sub-area for this feature?

PDE

Feature description

Whenever we click on "File > New", New sketch appears but it will be empty. We need to start writing setup and draw functions manually. I kindly request you to generate initial code on new sketch creation. (Maybe this feature can switched on/off in preferences)

Benefits

  • Developer can easily start writing his logic without writing basic functions every time

Possible challenges

No response

Additional context

No response

@SableRaf
Copy link
Collaborator

Thank you for the suggestion! One of the nice things about Processing is that even a single line of code is a valid program. There’s no need for setup or draw unless you want to change the sketch size or animate something. For this reason, we don’t plan to make this change.

@SableRaf SableRaf closed this as not planned Won't fix, can't repro, duplicate, stale Dec 26, 2024
@Stefterv
Copy link
Collaborator

Agreed but maybe we could allow users to define their starting sketch for themselves, like blender does with File->Defaults->Save Startup File

@hx2A
Copy link
Collaborator

hx2A commented Dec 27, 2024

I think there's a good idea here. What if the "Sketch" menu had an "insert template" submenu option, with a few choices like "basic animated sketch", that would insert something like this:

void setup() {
  size(500, 500);
  // write code that will be called once in this function
}

void draw() {
  // write code that will be called for every frame here
}

and maybe an "interactive sketch" option that had the above template plus more empty functions for the mouse and key events. And the comments in the template could match the user's language preferences.

This would be helpful for beginners because it would provide some guidance on code structure and also save them the time of looking up the names of the mouse and key event functions when they forget. And it would help me because I keep starting my Processing Sketches with "def setup()" by mistake...

@SableRaf SableRaf reopened this Dec 27, 2024
@SableRaf
Copy link
Collaborator

Good points both of you. I read a bit too quickly and didn't notice @nagesh007's suggestion to make it an optional setting. My apologies!

@Stefterv Stefterv moved this to Backlog in Processing Roadmap Jan 14, 2025
@Stefterv Stefterv added enhancement New feature or request help wanted Extra attention is needed pde Processing Development Environment labels Jan 21, 2025
@SushantBansal-tech
Copy link

@SableRaf Can you please assign this issue to me

@SableRaf
Copy link
Collaborator

Hi @SushantBansal-tech, I just assigned you. Thanks for picking this up! Let us know if you need any guidance. How are you thinking of approaching this issue?

@SushantBansal-tech
Copy link

SushantBansal-tech commented Mar 23, 2025

@SableRaf . Please provide some guidance I have discussed some thing about how I am approaching this issue

@SushantBansal-tech
Copy link

SushantBansal-tech commented Mar 23, 2025

@SableRaf I want to modify the Processing source code to automatically insert some default code whenever a new tab is created. However, I am having trouble understanding the interaction between Sketch.java, SketchCode.java, Editor.java, and PApplet.java.

Could you guide me on:

The execution order when a new tab is created.

Where I should modify the code to insert default content into a new tab.

How these classes interact when handling multiple tabs.

@SableRaf
Copy link
Collaborator

@SushantBansal-tech I'm leaning more towards the suggestion by @hx2A to have a new menu item for inserting a template.

What if the "Sketch" menu had an "insert template" submenu option, with a few choices like "basic animated sketch"

cc @Stefterv

@SushantBansal-tech
Copy link

@SableRaf okay I understand what we have to do
I will create a new menu in which certain templates will be provided

@Stefterv
Copy link
Collaborator

My personal preference would still be to define a file for a new sketch (shocker!), in any case please also think about how users of the PDE will be able to define their own templates to be inserted.

For the first iteration I think it is fine if those templates just get pasted into the editor tab you are looking at, later we can look at making that interaction a bit more refined if it needs it UX wise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed pde Processing Development Environment
Projects
Status: Backlog
Development

No branches or pull requests

5 participants