| 432 | } |
| 433 | |
| 434 | void PythonApp::createNewScript() { |
| 435 | if (_scriptCount >= MAX_SCRIPTS) return; |
| 436 | |
| 437 | // Generate a unique name |
| 438 | char name[MAX_FILENAME]; |
| 439 | for (int n = 1; n < 100; ++n) { |
| 440 | snprintf(name, sizeof(name), "script%d.py", n); |
| 441 | bool exists = false; |
| 442 | for (int i = 0; i < _scriptCount; ++i) { |
| 443 | if (strcmp(_scriptNames[i], name) == 0) { exists = true; break; } |
| 444 | } |
| 445 | if (!exists) break; |
| 446 | } |
| 447 | |
| 448 | // Create empty script |
| 449 | saveScript(name, "# New script\nprint('Hello!')\n"); |
| 450 | |
| 451 | // Reload and open in editor |
| 452 | loadScriptsList(); |
| 453 | refreshScriptList(); |
| 454 | |
| 455 | // Find the new script and open it |
| 456 | for (int i = 0; i < _scriptCount; ++i) { |
| 457 | if (strcmp(_scriptNames[i], name) == 0) { |
| 458 | openScriptInEditor(i); |
| 459 | return; |
| 460 | } |
| 461 | } |
| 462 | } |
| 463 | |
| 464 | void PythonApp::deleteScript(int idx) { |
| 465 | if (idx < 0 || idx >= _scriptCount) return; |
nothing calls this directly
no outgoing calls
no test coverage detected