Skip to content

Commit

Permalink
feat: add supress_output function to stop message output, use with ou…
Browse files Browse the repository at this point in the history
…tput_matrix for mercury drop-in
  • Loading branch information
twhiston committed May 11, 2023
1 parent 98b6c6a commit 5c50ec3
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 10 deletions.
52 changes: 45 additions & 7 deletions examples/editor-development/_editor-development.maxpat
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
,
"classnamespace" : "box",
"rect" : [ 888.0, 66.0, 545.0, 841.0 ],
"rect" : [ 638.0, 66.0, 642.0, 841.0 ],
"bglocked" : 0,
"openinpresentation" : 0,
"default_fontsize" : 12.0,
Expand Down Expand Up @@ -39,13 +39,37 @@
"subpatcher_template" : "",
"assistshowspatchername" : 0,
"boxes" : [ {
"box" : {
"id" : "obj-49",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 417.0, 410.0, 101.0, 22.0 ],
"text" : "supress_output 1"
}

}
, {
"box" : {
"id" : "obj-48",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 417.0, 377.0, 101.0, 22.0 ],
"text" : "supress_output 0"
}

}
, {
"box" : {
"id" : "obj-47",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 299.0, 477.0, 112.0, 22.0 ],
"patching_rect" : [ 292.0, 477.0, 112.0, 22.0 ],
"text" : "ephemeral_mode 0"
}

Expand All @@ -57,7 +81,7 @@
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 299.0, 447.0, 112.0, 22.0 ],
"patching_rect" : [ 292.0, 447.0, 112.0, 22.0 ],
"text" : "ephemeral_mode 1"
}

Expand Down Expand Up @@ -92,7 +116,7 @@
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 299.0, 410.0, 113.0, 22.0 ],
"patching_rect" : [ 292.0, 410.0, 113.0, 22.0 ],
"text" : "ignore_keys_id 100"
}

Expand All @@ -104,7 +128,7 @@
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 299.0, 377.0, 119.0, 22.0 ],
"patching_rect" : [ 292.0, 377.0, 119.0, 22.0 ],
"text" : "ignore_keys_id 8706"
}

Expand Down Expand Up @@ -978,8 +1002,8 @@
"numinlets" : 1,
"numoutlets" : 3,
"outlettype" : [ "", "", "" ],
"patching_rect" : [ 244.5, 245.0, 159.0, 22.0 ],
"text" : "tw.gl.repl editor-dev 588 258"
"patching_rect" : [ 244.5, 245.0, 267.0, 22.0 ],
"text" : "tw.gl.repl editor-dev 588 258 @supress_output 1"
}

}
Expand Down Expand Up @@ -1234,6 +1258,20 @@
"source" : [ "obj-47", 0 ]
}

}
, {
"patchline" : {
"destination" : [ "obj-31", 0 ],
"source" : [ "obj-48", 0 ]
}

}
, {
"patchline" : {
"destination" : [ "obj-31", 0 ],
"source" : [ "obj-49", 0 ]
}

}
, {
"patchline" : {
Expand Down
17 changes: 16 additions & 1 deletion javascript/src/MaxBindings/MaxBindingGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ function getCustomFunctionDefinitions(): Array<Object> {
functionName: "output_matrix",
handlerInlet: 0,
isMethod: true,
isAttribute: false,
isAttribute: true,
paramCount: 1,
params: [
{
Expand All @@ -206,6 +206,21 @@ function getCustomFunctionDefinitions(): Array<Object> {
],
comment: "If true then also output the text matrix name behind the command routing jit_matrix when code is run. Note that this does not stop other messages being output from the repl"
});
genFuncs.push({
functionName: "supress_output",
handlerInlet: 0,
isMethod: true,
isAttribute: true,
paramCount: 1,
params: [
{
name: "v",
default: false,
type: "bang/int",
}
],
comment: "If true then dont output the formatted messages. Can be used with output_matrix to only output the jit_matrix name from the repl"
});
genFuncs.push({
functionName: "ephemeral_mode",
handlerInlet: 0,
Expand Down
19 changes: 17 additions & 2 deletions javascript/src/MaxBindings/templates/main.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ function output_matrix(v) {
}
}

/**
* If SUPRESS_OUTPUT === true then dont output the formatted messages.
* Can be used with output_matrix to only output the jit_matrix name from the repl
*/
var SUPRESS_OUTPUT = false;
function supress_output(v){
if(v === undefined){
SUPRESS_OUTPUT = !SUPRESS_OUTPUT
} else {
SUPRESS_OUTPUT = v != 0;
}
}

/**
* If EPHEMERAL_MODE === true then the buffer will clear every time you run/execute
* If you run all it will empty all, if you run line it will empty the current line
Expand Down Expand Up @@ -131,8 +144,10 @@ function run_line() {
}

function run_output(out){
for (var a = 0; a < out.length; a++) {
outlet(0, out[a]);
if(SUPRESS_OUTPUT === false){
for (var a = 0; a < out.length; a++) {
outlet(0, out[a]);
}
}
if (OUT_MAT) {
outlet(0, "jit_matrix " + i.glRender.textMtx.name);
Expand Down

0 comments on commit 5c50ec3

Please sign in to comment.