Skip to content

Commit

Permalink
number of workbenches increased from 10 to 20
Browse files Browse the repository at this point in the history
# TwentyWorkspaces

Modifications to increase number of Workspaces from 10 to 20

## Changed files :

.\app\gui\qt\mainwindow.h
.\app\gui\qt\mainwindow.cpp
.\app\api\src\sonicpi_api.cpp
.\app\api\src\string_utils.cpp

## Result

20 Workspace tabs instead of 10

next/previous keyboard shortcuts "S-M-[/S-M-]" work

Each Workspace is saved to "~\.sonic-pi\store\default\"  and reloaded at startup
  • Loading branch information
colba committed Nov 28, 2024
1 parent a3bdf9b commit 061ba65
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 2 deletions.
47 changes: 47 additions & 0 deletions TwentyWorkSpaces.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# TwentyWorkspaces

Modifications to increase number of Workspaces from 10 to 20

## Changed files :

.\app\gui\qt\mainwindow.h
.\app\gui\qt\mainwindow.cpp
.\app\api\src\sonicpi_api.cpp
.\app\api\src\string_utils.cpp

## Result

20 Workspace tabs instead of 10

next/previous keyboard shortcuts "S-M-[/S-M-]" work

Each Workspace is saved to "~\.sonic-pi\store\default\" and reloaded at startup

"~\.sonic-pi\store\default\workspace_4teen.spi"
"~\.sonic-pi\store\default\workspace_6teen.spi"
"~\.sonic-pi\store\default\workspace_7teen.spi"
"~\.sonic-pi\store\default\workspace_8teen.spi"
"~\.sonic-pi\store\default\workspace_9teen.spi"
"~\.sonic-pi\store\default\workspace_eight.spi"
"~\.sonic-pi\store\default\workspace_eleven.spi"
"~\.sonic-pi\store\default\workspace_fifteen.spi"
"~\.sonic-pi\store\default\workspace_five.spi"
"~\.sonic-pi\store\default\workspace_four.spi"
"~\.sonic-pi\store\default\workspace_nine.spi"
"~\.sonic-pi\store\default\workspace_one.spi"
"~\.sonic-pi\store\default\workspace_seven.spi"
"~\.sonic-pi\store\default\workspace_six.spi"
"~\.sonic-pi\store\default\workspace_ten.spi"
"~\.sonic-pi\store\default\workspace_thirteen.spi"
"~\.sonic-pi\store\default\workspace_three.spi"
"~\.sonic-pi\store\default\workspace_twelve.spi"
"~\.sonic-pi\store\default\workspace_two.spi"
"~\.sonic-pi\store\default\workspace_zero.spi"

* Note the names had to be chosen to avoid incorrect number/name matching
* i.e. workspace 14 as fourteen, workspace 4 would match four and fourteen

## Future improvements :

1. change Workspace number/name conversion to work for any number creating a unique name match.
2. make the number of Workspaces configurable in Preferences
2 changes: 1 addition & 1 deletion app/api/src/sonicpi_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ void SonicPiAPI::Stop()

uint32_t SonicPiAPI::MaxWorkspaces() const
{
return 10;
return 20; // was 10
}

void SonicPiAPI::LoadWorkspaces()
Expand Down
60 changes: 60 additions & 0 deletions app/api/src/string_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,26 @@ std::string string_number_name(int i)
return "eight";
case 9:
return "nine";
case 10:
return "ten";
case 11:
return "eleven";
case 12:
return "twelve";
case 13:
return "thirteen";
case 14:
return "4teen";
case 15:
return "fifteen";
case 16:
return "6teen";
case 17:
return "7teen";
case 18:
return "8teen";
case 19:
return "9teen";
default:
assert(false);
return "";
Expand Down Expand Up @@ -149,6 +169,46 @@ uint32_t string_number_from_name(const std::string& name)
{
return 9;
}
if (name.find("ten") != std::string::npos)
{
return 10;
}
else if (name.find("eleven") != std::string::npos)
{
return 11;
}
else if (name.find("twelve") != std::string::npos)
{
return 12;
}
else if (name.find("thirteen") != std::string::npos)
{
return 13;
}
else if (name.find("4teen") != std::string::npos)
{
return 14;
}
else if (name.find("fifteen") != std::string::npos)
{
return 15;
}
else if (name.find("6teen") != std::string::npos)
{
return 16;
}
else if (name.find("7teen") != std::string::npos)
{
return 17;
}
else if (name.find("8teen") != std::string::npos)
{
return 18;
}
else if (name.find("9teen") != std::string::npos)
{
return 19;
}
return 0;
}

Expand Down
20 changes: 20 additions & 0 deletions app/gui/qt/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1656,6 +1656,26 @@ std::string MainWindow::number_name(int i)
return "eight";
case 9:
return "nine";
case 10:
return "ten";
case 11:
return "eleven";
case 12:
return "twelve";
case 13:
return "thirteen";
case 14:
return "4teen";
case 15:
return "fifteen";
case 16:
return "6teen";
case 17:
return "7teen";
case 18:
return "8teen";
case 19:
return "9teen";
default:
assert(false);
return "";
Expand Down
2 changes: 1 addition & 1 deletion app/gui/qt/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ private slots:
QSplashScreen* splash;

bool i18n;
static const int workspace_max = 10;
static const int workspace_max = 20; // was 10
SonicPiScintilla* workspaces[workspace_max];
QTabWidget* docsNavTabs;
QTabWidget* southTabs;
Expand Down

0 comments on commit 061ba65

Please sign in to comment.