Commit 95941f80 authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

allow pdsend to take multiple arguments

parent 10897757
......@@ -491,7 +491,7 @@ function apply() {
gop = +document.getElementsByName('gop')[0].checked;
hide_name = +document.getElementsByName('hide-name')[0].checked;
pdgui.pdsend([pd_object_callback, 'donecanvasdialog',
pdgui.pdsend(pd_object_callback, 'donecanvasdialog',
+get_input('x-scale'),
+get_input('y-scale'),
(gop + 2 * hide_name),
......@@ -503,7 +503,7 @@ function apply() {
+get_input('y-pix'),
+get_input('x-margin'),
+get_input('y-margin'),
].join(' '));
);
}
// Now send the array properties, in a separate
......@@ -514,7 +514,7 @@ function apply() {
if (name.slice(0, 1) === '$') {
name = '#' + name.slice(1);
}
pdgui.pdsend([
pdgui.pdsend(
get_array_value('array_gfxstub', attrs),
'arraydialog',
name,
......@@ -526,7 +526,7 @@ function apply() {
0, // ydraw-- not sure if this is still used
get_array_value('array_fill', attrs),
get_array_value('array_outline', attrs),
].join(' '));
);
}
}
......@@ -535,11 +535,11 @@ function cancel() {
var i, attrs, gfxstub;
pdgui.gui_post("closing the window at this point");
//window.close(true);
pdgui.pdsend(pd_object_callback + " cancel");
pdgui.pdsend(pd_object_callback, "cancel");
for (i = 0; i < pd_garray_attrs.length; i++) {
attrs = pd_garray_attrs[i];
gfxstub = attrs.array_gfxstub;
pdgui.pdsend(gfxstub + " cancel");
pdgui.pdsend(gfxstub, "cancel");
}
}
......
......@@ -118,18 +118,18 @@ function change_size() {
function apply() {
pdgui.gui_post("we're applying font size changes!");
pdgui.pdsend([canvas, 'font',
pdgui.pdsend(canvas, 'font',
+document.querySelector('input[name="font_size"]:checked').value,
current_size,
100,
0, // "$noundo" from pd.tk-- not sure what it does
].join(' '));
);
}
function cancel() {
pdgui.gui_post("closing the window at this point");
//window.close(true);
pdgui.pdsend(pd_object_callback + " cancel");
pdgui.pdsend(pd_object_callback, "cancel");
}
// This gets called from the nw_create_window function in index.html
......
......@@ -186,7 +186,7 @@ function gatom_escape(str) {
function apply() {
pdgui.gui_post("we're applying gatom changes!");
pdgui.pdsend([pd_object_callback, 'param',
pdgui.pdsend(pd_object_callback, 'param',
+document.getElementById('width').value,
+document.getElementById('minimum-range').value,
+document.getElementById('maximum-range').value,
......@@ -194,13 +194,13 @@ function apply() {
document.querySelector('input[name="labelpos"]:checked').value,
gatom_escape(document.getElementById('receive-symbol').value),
gatom_escape(document.getElementById('send-symbol').value)
].join(' '));
);
}
function cancel() {
pdgui.gui_post("closing the window at this point");
//window.close(true);
pdgui.pdsend(pd_object_callback + " cancel");
pdgui.pdsend(pd_object_callback, "cancel");
}
// This gets called from the nw_create_window function in index.html
......@@ -272,7 +272,7 @@ function add_events(name) {
// closing the Window
nw.Window.get().on("close", function() {
// this needs to do whatever the "cancel" button does
//pdgui.pdsend(name + " menuclose 0");
//pdgui.pdsend(name, "menuclose 0");
//cancel();
pdgui.remove_dialogwin(pd_object_callback);
this.close(true);
......
......@@ -448,7 +448,7 @@ function apply() {
var slot18 = +document.getElementsByName('steady-on-click')[0].checked;
pdgui.pdsend([pd_object_callback, 'dialog',
pdgui.pdsend(pd_object_callback, 'dialog',
width, height,
slot3, // bng: flash-interrupt
// slider: min-range
......@@ -468,13 +468,13 @@ function apply() {
background_color, foreground_color,
label_color,
slot18, // steady on click
0].join(' '));
0);
}
function cancel() {
pdgui.gui_post("closing the window at this point");
//window.close(true);
pdgui.pdsend(pd_object_callback + " cancel");
pdgui.pdsend(pd_object_callback, "cancel");
}
// This gets called from the nw_create_window function in index.html
......@@ -557,7 +557,7 @@ function add_events(name) {
// closing the Window
nw.Window.get().on("close", function() {
// this needs to do whatever the "cancel" button does
//pdgui.pdsend(name + " menuclose 0");
//pdgui.pdsend(name, "menuclose 0");
//cancel();
pdgui.remove_dialogwin(pd_object_callback);
this.close(true);
......
......@@ -351,7 +351,7 @@ function apply() {
pdgui.gui_post("we're applying shits!");
// Audio dialog
pdgui.pdsend([
pdgui.pdsend(
'pd audio-dialog',
kludge_dev('in', attrs, 0),
kludge_dev('in', attrs, 1),
......@@ -373,11 +373,11 @@ function apply() {
get_attr('advance', attrs),
get_attr('cancallback', attrs),
get_attr('blocksize', attrs)
].join(' '));
);
attrs = pd_midi_attrs;
// Midi dialog
pdgui.pdsend([
pdgui.pdsend(
'pd midi-dialog',
get_attr('pd-indevs', attrs)[0],
get_attr('pd-indevs', attrs)[1],
......@@ -389,23 +389,23 @@ function apply() {
get_attr('pd-outdevs', attrs)[3],
0, // midi_alsain
0 // midi_alsaout
].join(' '));
);
}
function cancel() {
var i, attrs, gfxstub;
pdgui.gui_post("closing the window at this point");
window.close(true);
//pdgui.pdsend(pd_object_callback + " cancel");
//pdgui.pdsend(pd_object_callback, "cancel");
}
function change_api(elem) {
var id = elem.getAttribute('id'),
value = elem.getAttribute('value');
if (id === 'audio_api') {
pdgui.pdsend("pd audio-setapi " + value);
pdgui.pdsend("pd audio-setapi", value);
} else {
pdgui.pdsend("pd midi-setapi " + value);
pdgui.pdsend("pd midi-setapi", value);
}
}
......
......@@ -45,7 +45,7 @@
document.getElementById("dsp_control").addEventListener("click",
function(evt) {
var dsp_state = this.checked ? 1 : 0;
pdgui.pdsend("pd dsp " + dsp_state);
pdgui.pdsend("pd dsp", dsp_state);
}
);
......
......@@ -260,13 +260,13 @@ function canvas_check_geometry(cid) {
win_y = patchwin[cid].y,
cnv_width = patchwin[cid].window.innerWidth,
cnv_height = patchwin[cid].window.innerHeight;
pdsend([cid, "relocate",
pdsend(cid, "relocate",
pd_geo_string(win_w, win_h, win_x, win_y),
// We're reusing win_x and win_y here, as it
// shouldn't make a difference to the bounds
// algorithm in Pd
pd_geo_string(cnv_width, cnv_height, win_x, win_y),
].join(" "));
);
}
exports.canvas_check_geometry = canvas_check_geometry;
......@@ -321,8 +321,7 @@ function saveas_callback(cid, file) {
//}
var directory = path.dirname(filename);
var basename = path.basename(filename);
pdsend(cid + " savetofile " + enquote(basename) + " " +
enquote(directory));
pdsend(cid, "savetofile", enquote(basename), enquote(directory));
// haven't implemented these last few commands yet...
// set untitled_directory $directory
......@@ -341,8 +340,8 @@ exports.menu_saveas = menu_saveas;
function menu_new () {
//if { ! [file isdirectory $untitled_directory]} {set untitled_directory $::env(HOME)}
untitled_directory = pwd;
pdsend("pd filename " +
"Untitled-" + untitled_number + " " +
pdsend("pd filename",
"Untitled-" + untitled_number,
enquote(untitled_directory));
if (k12_mode == 1) {
k12_saveas_on_new = 1;
......@@ -476,7 +475,7 @@ function open_file(file) {
//}
}
if (basename.match(/\.(pd|pat|mxt)$/i) != null) {
pdsend("pd open" + " " + enquote(basename) + " " + enquote(directory));
pdsend("pd open", enquote(basename), enquote(directory));
pd_opendir = directory;
//::pd_guiprefs::update_recentfiles "$filename" 1
}
......@@ -597,7 +596,7 @@ function gui_startup(version, fontname_from_pd, fontweight_from_pd,
// } else {
// set oldtclversion 0
// }
pdsend("pd init " + enquote(pwd) + " 0 " + font_fixed_metrics);
pdsend("pd init", enquote(pwd), "0", font_fixed_metrics);
// # add the audio and help menus to the Pd window. We delayed this
// # so that we'd know the value of "apilist".
......@@ -698,14 +697,9 @@ function gui_canvas_cursor(cid, pd_event_type) {
}
function gui_canvas_sendkey(cid, state, evt, char_code) {
pdsend(
cid + " key " +
state + " " +
char_code + " " +
(evt.shiftKey ? 1 : 0) + " " +
1 + " " +
(evt.repeat ? 1 : 0)
);
var shift = evt.shiftKey ? 1 : 0,
repeat = evt.repeat ? 1 : 0;
pdsend(cid, "key", state, char_code, shift, 1, repeat);
}
exports.gui_canvas_sendkey = gui_canvas_sendkey;
......@@ -901,7 +895,8 @@ function init_socket_events () {
exports.init_socket_events = init_socket_events;
// Send commands to Pd
function pdsend(string) {
function pdsend() {
var string = Array.prototype.join.call(arguments, ' ');
client.write(string + ';');
// for now, let's reprint the outgoing string to the pdwindow
//gui_post(string + ';', 'red');
......@@ -2206,7 +2201,7 @@ function gui_drawimage_new(obj_tag, file_path, canvasdir, flags) {
if (i > 0) {
img = new pd_window.Image(); // create an image in the pd_window context
img.onload = function() {
pdsend(obj_tag + ' size ' + this.width + ' ' + this.height);
pdsend(obj_tag, "size", this.width, this.height);
};
img.src = 'data:image/' + drawimage_data[obj_tag][0].type +
';base64,' + drawimage_data[obj_tag][0].data;
......@@ -2338,7 +2333,7 @@ function gui_canvas_popup(cid, xpos, ypos, canprop, canopen, isobject) {
}
function popup_action(cid, index) {
pdsend(cid + " done-popup " + index + " " + popup_coords.join(" "));
pdsend(cid, "done-popup", index, popup_coords.join(" "));
}
exports.popup_action = popup_action;
......@@ -2563,7 +2558,7 @@ function gui_savepanel(cid, target, path) {
}
exports.file_dialog_callback = function(file_string) {
pdsend(file_dialog_target + " callback " + enquote(file_string));
pdsend(file_dialog_target, "callback", enquote(file_string));
}
// Used to convert the ["key", "value"...] arrays coming from
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment