Skip to content

Commit 7514ebb

Browse files
committed
Fix code editor bug, add man pages to command input
1 parent 3b91ea0 commit 7514ebb

File tree

4 files changed

+68
-6
lines changed

4 files changed

+68
-6
lines changed

Source/Dialogs/TextEditorDialog.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ class Memoizer {
670670
return this->operator()(argument);
671671
}
672672
FunctionType f;
673-
mutable HashMap<ArgType, DataType> map;
673+
mutable UnorderedMap<ArgType, DataType> map;
674674
};
675675

676676
/**
@@ -857,7 +857,7 @@ class GlyphArrangementArray {
857857
void clear() { lines.clear(); }
858858
void add(String const& string) { lines.add(string); }
859859
void insert(int index, String const& string) { lines.insert(index, string); }
860-
void removeRange(int startIndex, int numberToRemove) { lines.remove_range(startIndex, numberToRemove); }
860+
void removeRange(int startIndex, int numberToRemove) { lines.remove_range(startIndex, startIndex + numberToRemove); }
861861
String const& operator[](int index) const;
862862

863863
int getToken(int row, int col, int defaultIfOutOfBounds) const;

Source/Objects/LuaObject.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class LuaObject final : public ObjectBase
2222
, private Value::Listener {
2323
Colour currentColour;
2424

25-
CriticalSection bufferSwapLock;
2625
bool isSelected = false;
2726
Value zoomScale;
2827
std::unique_ptr<Component> textEditor;

Source/Sidebar/CommandInput.h

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ class CommandInput final
446446
cnv->setSelected(object, true);
447447
cnv->updateSidebarSelection();
448448
}
449+
if(objects.empty()) pd->logError("No object found for: " + tokens[1]);
449450
// TODO: fix highlighting!
450451
//if(objects.size()) editor->highlightSearchTarget(objects[0]->getPointer(), true);
451452
}
@@ -535,15 +536,72 @@ class CommandInput final
535536
}
536537
cnv->patch.deselectAll();
537538
}
539+
else {
540+
pd->logError("No canvas open");
541+
}
538542
}
539543
case hash("script"):
540544
{
541545
auto script = pd::Library::findFile(tokens[1] + ".lua");
542546
if(script.existsAsFile()) {
543547
lua->executeScript(script.getFullPathName());
544548
}
549+
else {
550+
pd->logError("Script not found");
551+
}
545552
break;
546553
}
554+
case hash("man"):
555+
{
556+
switch(hash(tokens[1]))
557+
{
558+
case hash("man"):
559+
pd->logMessage("Prints manual for command. Usage: man <command>");
560+
break;
561+
562+
case hash("?"):
563+
case hash("help"):
564+
pd->logMessage(tokens[2] + ": Show help");
565+
break;
566+
567+
case hash("script"):
568+
pd->logMessage(tokens[2] + ": Excute a Lua script from your search path. Usage: script <filename>");
569+
break;
570+
571+
case hash("cnv"):
572+
case hash("canvas"):
573+
pd->logMessage(tokens[2] + ": Send a message to current canvas. Usage: " + tokens[2] + " <message>");
574+
break;
575+
576+
case hash("clear"):
577+
pd->logMessage(tokens[2] + ": Clear console and command history");
578+
break;
579+
580+
case hash("reset"):
581+
pd->logMessage(tokens[2] + ": Reset Lua interpreter state");
582+
break;
583+
584+
case hash("sel"):
585+
case hash("select"):
586+
pd->logMessage(tokens[2] + ": Select an object by ID or index. After selecting objects, you can send messages to them. Usage: " + tokens[2] + " <id> or " + tokens[2] + " <index>");
587+
break;
588+
589+
case hash(">"):
590+
case hash("deselect"):
591+
pd->logMessage(tokens[2] + ": Deselects all on current canvas");
592+
break;
593+
594+
case hash("ls"):
595+
case hash("list"):
596+
pd->logMessage(tokens[2] + ": Print a list of all object IDs on current canvas");
597+
break;
598+
599+
case hash("find"):
600+
case hash("search"):
601+
pd->logMessage(tokens[2] + ": Search object IDs on current canvas. Usage: " + tokens[2] + " <id>.");
602+
break;
603+
}
604+
}
547605
case hash("?"):
548606
case hash("help"):
549607
{
@@ -558,18 +616,21 @@ class CommandInput final
558616
if(tokens.size() == 2)
559617
{
560618
if(auto* cnv = editor->getCurrentCanvas()) {
561-
for(auto* object : findObjects(cnv, target)) {
619+
auto objects = findObjects(cnv, target);
620+
for(auto* object : objects) {
562621
cnv->setSelected(object, true);
563622
cnv->updateSidebarSelection();
564623
}
624+
if(objects.empty()) pd->logError("No object found for: " + tokens[1]);
565625
}
566626
break;
567627
}
568628

569629
tokens.removeRange(0, 2);
570630

571631
if(auto* cnv = editor->getCurrentCanvas()) {
572-
for(auto* object : findObjects(cnv, target)) {
632+
auto objects = findObjects(cnv, target);
633+
for(auto* object : objects) {
573634
if(auto* cnv = editor->getCurrentCanvas())
574635
{
575636
auto objPtr = object->getPointer();
@@ -590,6 +651,7 @@ class CommandInput final
590651
}
591652
}
592653
}
654+
if(objects.empty()) pd->logError("No object found for: " + tokens[1]);
593655
}
594656
}
595657

@@ -783,6 +845,7 @@ class CommandInput final
783845
"Command input allows you to quickly send commands to objects, pd or the canvas.\n"
784846
"The following commands are available:\n"
785847
"\n"
848+
"- man <command>: print manual for command\n"
786849
"- list/ls: list all object IDs in the current canvas\n"
787850
"- search: search for an object ID in current canvas\n"
788851
"- select/sel <id>: selects an object\n"

Source/Statusbar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ class CPUMeter : public Component
10241024
void cpuUsageChanged(float newCpuUsage) override
10251025
{
10261026
ScopedLock lock(cpuMeterMutex);
1027-
cpuUsage.push(newCpuUsage); // FIXME: we should use a circular buffer instead
1027+
cpuUsage.push(newCpuUsage);
10281028
updateCPUGraph();
10291029
}
10301030

0 commit comments

Comments
 (0)