Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Jonathan Wilkes
purr-data
Commits
aa659330
Commit
aa659330
authored
May 01, 2018
by
Jonathan Wilkes
Browse files
Merge branch 'hyperlinked-print'
parents
cd9cd9cb
ab4741da
Pipeline
#1283
passed with stage
in 341 minutes and 35 seconds
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
pd/nw/pdgui.js
View file @
aa659330
...
...
@@ -659,30 +659,50 @@ var last_child = {};
var
last_object_id
=
""
;
var
duplicate
=
0
;
function
do_post
(
string
,
type
)
{
var
myp
,
span
,
text
,
printout
;
current_string
+=
string
;
myp
=
pd_window
.
document
.
getElementById
(
"
p1
"
);
function
do_post
(
object_id
,
selector
,
string
,
type
,
loglevel
)
{
var
my_p
,
my_a
,
span
,
text
,
sel_span
,
printout
,
dup_span
;
current_string
=
current_string
+
(
selector
?
selector
:
""
)
+
string
;
my_p
=
pd_window
.
document
.
getElementById
(
"
p1
"
);
// We can get posts from Pd that are build incrementally, with the final
// message having a "\n" at the end. So we test for that.
if
(
string
.
slice
(
-
1
)
===
"
\n
"
)
{
if
(
current_string
===
last_string
)
{
last_child
.
textContent
=
"
[
"
+
(
duplicate
+
2
)
+
"
]
"
+
last_string
;
duplicate
++
;
if
(
current_string
===
last_string
&&
object_id
===
last_object_id
)
{
duplicate
+=
1
;
dup_span
=
last_child
.
firstElementChild
;
dup_span
.
textContent
=
"
[
"
+
(
duplicate
+
1
)
+
"
]
"
;
current_string
=
""
;
if
(
myp
.
lastChild
!==
last_child
)
{
myp
.
appendChild
(
last_child
);
if
(
my
_
p
.
lastChild
!==
last_child
)
{
my
_
p
.
appendChild
(
last_child
);
}
}
else
{
span
=
pd_window
.
document
.
createElement
(
"
span
"
);
if
(
type
)
{
span
.
classList
.
add
(
type
);
}
text
=
pd_window
.
document
.
createTextNode
(
current_string
);
dup_span
=
pd_window
.
document
.
createElement
(
"
span
"
);
sel_span
=
pd_window
.
document
.
createTextNode
(
selector
?
selector
:
""
);
text
=
pd_window
.
document
.
createTextNode
(
(
selector
&&
selector
!==
""
)
?
"
:
"
+
string
:
current_string
);
if
(
object_id
&&
object_id
.
length
>
0
)
{
my_a
=
pd_window
.
document
.
createElement
(
"
a
"
);
my_a
.
href
=
"
javascript:pdgui.pd_error_select_by_id('
"
+
object_id
+
"
')
"
;
my_a
.
appendChild
(
sel_span
);
span
.
appendChild
(
dup_span
);
// duplicate tally
span
.
appendChild
(
my_a
);
}
else
{
span
.
appendChild
(
dup_span
);
span
.
appendChild
(
sel_span
);
my_p
.
appendChild
(
span
);
}
span
.
appendChild
(
text
);
myp
.
appendChild
(
span
);
my
_
p
.
appendChild
(
span
);
last_string
=
current_string
;
current_string
=
""
;
last_child
=
span
;
last_object_id
=
""
;
last_object_id
=
object_id
;
duplicate
=
0
;
// update the scrollbars to the bottom, but throttle it
// since it is expensive
...
...
@@ -693,14 +713,14 @@ function do_post(string, type) {
// print message to console-- add a newline for convenience
function
post
(
string
,
type
)
{
do_post
(
string
+
"
\n
"
,
type
);
do_post
(
null
,
null
,
string
+
"
\n
"
,
type
,
null
);
}
exports
.
post
=
post
;
// print message to console from Pd-- don't add newline
function
gui_post
(
string
,
type
)
{
do_post
(
string
,
type
);
do_post
(
null
,
""
,
string
,
type
,
null
);
}
function
pd_error_select_by_id
(
objectid
)
{
...
...
@@ -709,46 +729,21 @@ function pd_error_select_by_id(objectid) {
}
}
exports
.
pd_error_select_by_id
=
pd_error_select_by_id
exports
.
pd_error_select_by_id
=
pd_error_select_by_id
;
function
gui_post_error
(
objectid
,
loglevel
,
errormsg
)
{
var
my_p
,
error_span
,
error_title
,
my_a
,
rest
,
printout
,
dup_span
;
if
(
last_object_id
===
objectid
&&
last_string
===
errormsg
)
{
dup_span
=
last_child
.
firstElementChild
;
dup_span
.
textContent
=
"
[
"
+
(
duplicate
+
2
)
+
"
]
"
;
duplicate
++
;
}
else
{
my_p
=
pd_window
.
document
.
getElementById
(
"
p1
"
);
// if we have an object id, make a friendly link...
error_span
=
pd_window
.
document
.
createElement
(
"
span
"
);
error_span
.
classList
.
add
(
"
error
"
);
dup_span
=
pd_window
.
document
.
createElement
(
"
span
"
);
last_child
=
error_span
;
error_title
=
pd_window
.
document
.
createTextNode
(
"
error
"
);
if
(
objectid
.
length
>
0
)
{
my_a
=
pd_window
.
document
.
createElement
(
"
a
"
);
my_a
.
href
=
"
javascript:pdgui.pd_error_select_by_id('
"
+
objectid
+
"
')
"
;
my_a
.
appendChild
(
error_title
);
error_span
.
appendChild
(
dup_span
);
// for duplicate tally
error_span
.
appendChild
(
my_a
);
my_p
.
appendChild
(
error_span
);
}
else
{
error_span
.
appendChild
(
dup_span
);
error_span
.
appendChild
(
error_title
);
my_p
.
appendChild
(
error_span
);
}
rest
=
pd_window
.
document
.
createTextNode
(
"
:
"
+
errormsg
);
error_span
.
appendChild
(
rest
);
printout
=
pd_window
.
document
.
getElementById
(
"
console_bottom
"
);
printout
.
scrollTop
=
printout
.
scrollHeight
;
last_string
=
errormsg
;
last_object_id
=
objectid
;
current_string
=
""
;
duplicate
=
0
;
}
function
gui_post_error
(
objectid
,
loglevel
,
error_msg
)
{
do_post
(
objectid
,
"
error
"
,
error_msg
,
"
error
"
,
loglevel
);
}
// This is used specifically by [print] so that we can receive the full
// message in a single call. This way we can call do_post with a single
// string message and track the object id with the selector.
function
gui_print
(
object_id
,
selector
,
array_of_strings
)
{
// Unfortunately the instance finder still uses a "." prefix, so we
// have to add that here
do_post
(
"
.
"
+
object_id
,
selector
,
array_of_strings
.
join
(
"
"
)
+
"
\n
"
,
null
,
null
);
}
function
gui_legacy_tcl_command
(
file
,
line_number
,
text
)
{
...
...
pd/src/g_text.c
View file @
aa659330
...
...
@@ -167,8 +167,6 @@ static void canvas_objtext(t_glist *gl, int xpix, int ypix,
return
;
}
}
binbuf_print
(
b
);
post
(
"... couldn't create"
);
x
=
0
;
}
else
if
(
!
(
x
=
pd_checkobject
(
newest
)))
...
...
@@ -182,7 +180,16 @@ static void canvas_objtext(t_glist *gl, int xpix, int ypix,
{
/* LATER make the color reflect this */
x
=
(
t_text
*
)
pd_new
(
text_class
);
//fprintf(stderr,"creating blank object %lx\n", x);
if
(
binbuf_getnatom
(
b
))
{
int
bufsize
;
char
*
buf
;
binbuf_gettext
(
b
,
&
buf
,
&
bufsize
);
buf
=
t_resizebytes
(
buf
,
bufsize
,
bufsize
+
1
);
buf
[
bufsize
]
=
0
;
pd_error
(
x
,
"couldn't create
\"
%s
\"
"
,
buf
);
t_freebytes
(
buf
,
bufsize
+
1
);
}
}
/* special case: an object, like preset_hub, hides its arguments
beyond the first n, so we modify its binbuf here */
...
...
pd/src/s_print.c
View file @
aa659330
...
...
@@ -244,7 +244,7 @@ void pd_error(void *object, const char *fmt, ...)
{
/* move this to a function in the GUI so that we can change the
message without having to recompile */
post
(
"...
you might be abl
e to track t
his
down
from
the 'Find Last Error' item in the Edit menu
, or by clicking the error link above
."
);
post
(
"...
click the link abov
e to track
i
t down
, or click
the 'Find Last Error' item in the Edit menu."
);
saidit
=
1
;
}
}
...
...
pd/src/x_interface.c
View file @
aa659330
...
...
@@ -56,39 +56,55 @@ static void *print_new(t_symbol *sel, int argc, t_atom *argv)
static
void
print_bang
(
t_print
*
x
)
{
post
(
"%s%sbang"
,
x
->
x_sym
->
s_name
,
(
*
x
->
x_sym
->
s_name
?
": "
:
""
));
gui_start_vmess
(
"gui_print"
,
"xs"
,
x
,
x
->
x_sym
->
s_name
);
gui_start_array
();
gui_s
(
s_bang
.
s_name
);
gui_end_array
();
gui_end_vmess
();
}
static
void
print_pointer
(
t_print
*
x
,
t_gpointer
*
gp
)
{
post
(
"%s%s(gpointer)"
,
x
->
x_sym
->
s_name
,
(
*
x
->
x_sym
->
s_name
?
": "
:
""
));
gui_start_vmess
(
"gui_print"
,
"xs"
,
x
,
x
->
x_sym
->
s_name
);
gui_start_array
();
gui_s
(
"(gpointer)"
);
gui_end_array
();
gui_end_vmess
();
}
static
void
print_float
(
t_print
*
x
,
t_float
f
)
static
void
print_float
(
t_print
*
x
,
t_float
arg
f
)
{
post
(
"%s%s%g"
,
x
->
x_sym
->
s_name
,
(
*
x
->
x_sym
->
s_name
?
": "
:
""
),
f
);
gui_start_vmess
(
"gui_print"
,
"xs"
,
x
,
x
->
x_sym
->
s_name
);
gui_start_array
();
gui_f
(
f
);
gui_end_array
();
gui_end_vmess
();
}
static
void
print_
list
(
t_print
*
x
,
t_symbol
*
s
,
int
argc
,
t_atom
*
argv
)
static
void
print_
symbol
(
t_print
*
x
,
t_symbol
*
s
)
{
if
(
argc
&&
argv
->
a_type
!=
A_SYMBOL
)
startpost
(
"%s%s%g"
,
x
->
x_sym
->
s_name
,
(
*
x
->
x_sym
->
s_name
?
": "
:
""
),
atom_getfloatarg
(
0
,
argc
--
,
argv
++
));
else
startpost
(
"%s%s%s"
,
x
->
x_sym
->
s_name
,
(
*
x
->
x_sym
->
s_name
?
": "
:
""
),
(
argc
>
1
?
s_list
.
s_name
:
(
argc
==
1
?
s_symbol
.
s_name
:
s_bang
.
s_name
)));
postatom
(
argc
,
argv
);
endpost
();
gui_start_vmess
(
"gui_print"
,
"xs"
,
x
,
x
->
x_sym
->
s_name
);
gui_start_array
();
gui_s
(
s_symbol
.
s_name
);
gui_s
(
s
->
s_name
);
gui_end_array
();
gui_end_vmess
();
}
static
void
print_anything
(
t_print
*
x
,
t_symbol
*
s
,
int
argc
,
t_atom
*
argv
)
{
startpost
(
"%s%s%s"
,
x
->
x_sym
->
s_name
,
(
*
x
->
x_sym
->
s_name
?
": "
:
""
),
s
->
s_name
);
postatom
(
argc
,
argv
);
endpost
();
char
buf
[
MAXPDSTRING
];
gui_start_vmess
(
"gui_print"
,
"xs"
,
x
,
x
->
x_sym
->
s_name
);
gui_start_array
();
if
(
s
&&
(
s
!=
&
s_list
||
(
argc
&&
argv
->
a_type
!=
A_FLOAT
)))
gui_s
(
s
->
s_name
);
for
(;
argc
;
argv
++
,
argc
--
)
{
atom_string
(
argv
,
buf
,
MAXPDSTRING
);
gui_s
(
buf
);
}
gui_end_array
();
gui_end_vmess
();
}
static
void
print_setup
(
void
)
...
...
@@ -98,7 +114,7 @@ static void print_setup(void)
class_addbang
(
print_class
,
print_bang
);
class_addfloat
(
print_class
,
print_float
);
class_addpointer
(
print_class
,
print_pointer
);
class_add
list
(
print_class
,
print_
list
);
class_add
symbol
(
print_class
,
print_
symbol
);
class_addanything
(
print_class
,
print_anything
);
}
...
...
scripts/manual_tests/message_errors.pd
View file @
aa659330
#N canvas 3 60 508 4
25
10;
#X msg 21
4
1 \; \$1;
#X msg 21 1
3
1 \; \$0;
#X msg 21 2
2
0 42;
#X msg 21
25
1 \; \$1;
#X text 21
1
1 1) dollar target is out of range;
#X text 21 1
0
1 2) dollar target is dollar zero;
#X text 21
19
1 3) dollar target isn't a symbol;
#X text 251
1
1 4) not enough args to dollsym;
#X msg 251
6
7 \; \$1-foo;
#X msg 251
3
6 bang;
#X text 299
5
9 ERROR: double doll sign;
#X msg 251 1
3
0 bang;
#X text 251 1
0
1 5) no such object;
#X msg 251
16
1 \; 42;
#X msg 251 2
3
0 bang;
#X msg 251 2
6
1 \; foo \$1;
#X obj 329 2
2
8 r foo;
#X obj 329
25
0 == 0;
#X floatatom 329
27
2 5 0 0 0 - - -, f 5;
#X msg 251
3
40 bang;
#X text 251 2
0
1 6) dollar argument number out of range;
#X text 251 3
1
1 7) dollsym argument number out of range;
#X obj 379
36
0 sel 0-foo;
#X obj 379 3
3
8 r seven;
#X msg 251 3
7
1 \; seven symbol \$1-foo;
#X obj 430
38
2 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
#N canvas 3 60 508 4
97
10;
#X msg 21
10
1 \; \$1;
#X msg 21 1
9
1 \; \$0;
#X msg 21 2
8
0 42;
#X msg 21
31
1 \; \$1;
#X text 21
7
1 1) dollar target is out of range;
#X text 21 1
6
1 2) dollar target is dollar zero;
#X text 21
25
1 3) dollar target isn't a symbol;
#X text 251
7
1 4) not enough args to dollsym;
#X msg 251
12
7 \; \$1-foo;
#X msg 251
9
6 bang;
#X text 299
11
9 ERROR: double doll sign;
#X msg 251 1
9
0 bang;
#X text 251 1
6
1 5) no such object;
#X msg 251
22
1 \; 42;
#X msg 251 2
9
0 bang;
#X msg 251
3
21 \; foo \$1;
#X obj 329 2
8
8 r foo;
#X obj 329
31
0 == 0;
#X floatatom 329
33
2 5 0 0 0 - - -, f 5;
#X msg 251 4
0
0 bang;
#X text 251 2
6
1 6) dollar argument number out of range;
#X text 251 3
7
1 7) dollsym argument number out of range;
#X obj 379
42
0 sel 0-foo;
#X obj 379 3
9
8 r seven;
#X msg 251
4
31 \; seven symbol \$1-foo;
#X obj 430
44
2 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
-1 -1;
#X text 21 19 All of these should output an error with a link back
to the relevant message box.;
#X connect 2 0 3 0;
#X connect 9 0 8 0;
#X connect 11 0 13 0;
...
...
scripts/manual_tests/message
-
perf.pd
→
scripts/manual_tests/message
_
perf.pd
View file @
aa659330
File moved
scripts/manual_tests/print_output.pd
0 → 100644
View file @
aa659330
#N canvas 3 60 731 585 12;
#X msg 19 64 0;
#X obj 19 549 print;
#X text 130 63 "print: 0";
#X msg 31 101 foo bar;
#X obj 31 126 list split 1;
#X text 130 100 "print: symbol foo";
#X msg 46 160 list 0;
#X text 130 160 "print: 0";
#X msg 57 199 foo bar;
#X text 130 199 "print: foo bar";
#X msg 77 234 list;
#X msg 79 284 bang;
#X msg 85 325 bang;
#X obj 85 350 symbol;
#X msg 85 375 \$1;
#X text 130 234 "print: bang";
#X text 131 284 "print: bang";
#X text 131 324 "print: ";
#X msg 416 161 a 2;
#X text 529 161 "print: a 2";
#X msg 416 455 pointer;
#X obj 416 480 canvasinfo;
#X text 529 455 "print: (gpointer)";
#X msg 416 213 grapes;
#X obj 416 238 list;
#X text 529 213 "print: symbol grapes";
#X msg 416 125 symbol grapes;
#X text 529 125 "print: symbol grapes";
#X msg 416 279 pointer;
#X obj 416 304 canvasinfo;
#X msg 416 329 grapes \$1;
#X obj 416 505 pointer;
#X text 529 279 "print: grapes (pointer)";
#X msg 416 370 pointer;
#X obj 416 395 canvasinfo;
#X text 19 14 These should output the same text as Pd Vanilla which
is written in the comments.;
#X msg 416 75 2 a b;
#X text 529 75 "print: 2 a b";
#X msg 416 420 list \$1 \$1;
#X text 489 369 "print: list (pointer) (pointer)";
#X connect 0 0 1 0;
#X connect 3 0 4 0;
#X connect 4 0 1 0;
#X connect 6 0 1 0;
#X connect 8 0 1 0;
#X connect 10 0 1 0;
#X connect 11 0 1 0;
#X connect 12 0 13 0;
#X connect 13 0 14 0;
#X connect 14 0 1 0;
#X connect 18 0 1 0;
#X connect 20 0 21 0;
#X connect 21 0 31 0;
#X connect 23 0 24 0;
#X connect 24 0 1 0;
#X connect 26 0 1 0;
#X connect 28 0 29 0;
#X connect 29 0 30 0;
#X connect 30 0 1 0;
#X connect 31 0 1 0;
#X connect 33 0 34 0;
#X connect 34 0 38 0;
#X connect 36 0 1 0;
#X connect 38 0 1 0;
scripts/manual_tests/trigger
-
perf.pd
→
scripts/manual_tests/trigger
_
perf.pd
View file @
aa659330
File moved
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment