Commit 4ad7901a authored by pokergaming's avatar pokergaming
Browse files

Hyperlinked error messages to the console, plus some cleanup of the gui prefs

parent 04b0af36
......@@ -110,7 +110,7 @@ proc ::dialog_gui::set_gui_preset {args} {
set ::pd_colors(signal_cord) #808095
set ::pd_colors(signal_nlet) $::pd_colors(signal_cord)
set ::pd_colors(xlet_hover) grey
set ::pd_colors(link) #eb5f28
set ::pd_colors(link) "#eb5f28"
set ::pd_colors(selection) #e87216
set ::pd_colors(selection_rectangle) #e87216
set ::pd_colors(highlighted_text) black
......
......@@ -194,7 +194,7 @@ proc ::dialog_prefs::set_color {array key op} {
all_cords&&control -stroke $c"]}
selection {
set commands [list "itemconfigure \
selected&&text -fill $c"]
selected&&text&&(!box&&!iemgui) -fill $c"]
lappend commands "itemconfigure \
selected&&(border&&(!iemgui)) -fill $c"
lappend commands "itemconfigure \
......@@ -226,7 +226,10 @@ proc ::dialog_prefs::set_color {array key op} {
.search.navtext tag configure link -foreground $c
.search.f.advancedlabel configure -foreground $c
}
return
if {[winfo exists .printout.frame.text]} {
.printout.frame.text tag configure link -foreground $c
}
# return
}
default {}
}
......
......@@ -5053,13 +5053,19 @@ static int glist_dofinderror(t_glist *gl, void *error_object)
return (0);
}
extern t_class *messresponder_class;
void canvas_finderror(void *error_object)
{
t_canvas *x;
void *error_gobj = error_object;
/* Since the messresponder_class isn't patchable,
we climb up to the parent message_class addy. */
if(((t_gobj *)error_object)->g_pd == messresponder_class)
error_gobj = error_object - sizeof(t_text);
/* find all root canvases */
for (x = canvas_list; x; x = x->gl_next)
{
if (glist_dofinderror(x, error_object))
if (glist_dofinderror(x, error_gobj))
return;
}
post("... sorry, I couldn't find the source of that error.");
......
......@@ -530,7 +530,7 @@ typedef struct _message
t_clock *m_clock;
} t_message;
static t_class *messresponder_class;
t_class *messresponder_class;
static void messresponder_bang(t_messresponder *x)
{
......
......@@ -21,6 +21,7 @@ void glob_key(void *dummy, t_symbol *s, int ac, t_atom *av);
void glob_pastetext(void *dummy, t_symbol *s, int ac, t_atom *av);
void glob_audiostatus(void *dummy);
void glob_finderror(t_pd *dummy);
void glob_findinstance(t_pd *dummy, t_symbol*s);
void glob_audio_properties(t_pd *dummy, t_floatarg flongform);
void glob_audio_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv);
void glob_audio_setapi(t_pd *dummy, t_floatarg f);
......@@ -105,6 +106,8 @@ void glob_init(void)
gensym("audiostatus"), 0);
class_addmethod(glob_pdobject, (t_method)glob_finderror,
gensym("finderror"), 0);
class_addmethod(glob_pdobject, (t_method)glob_findinstance,
gensym("findinstance"), A_SYMBOL, 0);
class_addmethod(glob_pdobject, (t_method)glob_audio_properties,
gensym("audio-properties"), A_DEFFLOAT, 0);
class_addmethod(glob_pdobject, (t_method)glob_audio_dialog,
......
......@@ -944,6 +944,35 @@ proc pdtk_post {stuff} {
.printout.frame.text configure -state disabled
}
proc pderror_select_by_id {objectid} {
if [llength $objectid] {
pdsend "pd findinstance $objectid"
}
}
# stopgap for ::pdwindow::logpost
proc pdtk_posterror {objectid loglevel errormsg} {
set t .printout.frame.text
$t configure -state normal
# if we have an object id, make a friendly link...
if {$objectid ne ""} {
$t insert end "error" [list obj$objectid link]
$t tag bind obj$objectid <1> "pderror_select_by_id $objectid; break"
$t tag bind obj$objectid <Enter> "$t configure -cursor hand2"
$t tag bind obj$objectid <Leave> "$t configure -cursor xterm"
$t tag configure link -foreground "$::pd_colors(link)" \
-underline on
} else {
$t insert end "error"
}
$t insert end ": "
$t insert end $errormsg
after cancel .printout.frame.text yview end-2char
after idle .printout.frame.text yview end-2char
.printout.frame.text configure -state disabled
}
proc pdtk_standardkeybindings {id} {
global pd_nt ctrl_key
bind $id <$ctrl_key-Key> {pdtk_canvas_ctrlkey %W %K 0}
......
......@@ -13,6 +13,58 @@
t_printhook sys_printhook;
int sys_printtostderr;
/* escape characters for tcl/tk */
static char* strnescape(char *dest, const char *src, size_t len)
{
int ptin = 0;
unsigned ptout = 0;
for(; ptout < len; ptin++, ptout++)
{
int c = src[ptin];
if (c == '\\' || c == '{' || c == '}')
dest[ptout++] = '\\';
dest[ptout] = src[ptin];
if (c==0) break;
}
if(ptout < len)
dest[ptout]=0;
else
dest[len-1]=0;
return dest;
}
static char* strnpointerid(char *dest, const void *pointer, size_t len)
{
*dest=0;
if (pointer)
snprintf(dest, len, ".x%lx", (unsigned long)pointer);
return dest;
}
static void doerror(const void *object, const char *s)
{
char upbuf[MAXPDSTRING];
upbuf[MAXPDSTRING-1]=0;
// what about sys_printhook_error ?
if (sys_printhook)
{
snprintf(upbuf, MAXPDSTRING-1, "error: %s", s);
(*sys_printhook)(upbuf);
}
else if (sys_printtostderr)
fprintf(stderr, "error: %s", s);
else
{
char obuf[MAXPDSTRING];
sys_vgui("pdtk_posterror {%s} 1 {%s}\n",
strnpointerid(obuf, object, MAXPDSTRING),
strnescape(upbuf, s, MAXPDSTRING));
}
}
static void dopost(const char *s)
{
if (sys_printhook)
......@@ -102,12 +154,13 @@ void error(const char *fmt, ...)
va_list ap;
t_int arg[8];
int i;
dopost("error: ");
va_start(ap, fmt);
vsnprintf(buf, MAXPDSTRING-1, fmt, ap);
va_end(ap);
strcat(buf, "\n");
dopost(buf);
doerror(NULL, buf);
}
void verbose(int level, const char *fmt, ...)
......@@ -143,12 +196,14 @@ void pd_error(void *object, const char *fmt, ...)
t_int arg[8];
int i;
static int saidit;
dopost("error: ");
va_start(ap, fmt);
vsnprintf(buf, MAXPDSTRING-1, fmt, ap);
va_end(ap);
strcat(buf, "\n");
dopost(buf);
doerror(object, buf);
error_object = object;
if (!saidit)
{
......@@ -169,6 +224,19 @@ void glob_finderror(t_pd *dummy)
}
}
void glob_findinstance(t_pd *dummy, t_symbol*s)
{
// revert s to (potential) pointer to object
long obj = 0;
if (sscanf(s->s_name, ".x%lx", &obj))
{
if (obj)
{
canvas_finderror((void *)obj);
}
}
}
void bug(const char *fmt, ...)
{
char buf[MAXPDSTRING];
......
......@@ -358,6 +358,13 @@ static void sel1_proxy_symbol(t_sel1_proxy *x, t_symbol *s)
SETSYMBOL(&p->x_atom, s);
}
static void sel1_proxy_anything(t_sel1_proxy *x, t_symbol *s, int argc,
t_atom *argv)
{
t_sel1 *parent = (t_sel1 *)x->parent;
pd_error(parent, "select: no method for %s", s->s_name);
}
static void sel1_float(t_sel1 *x, t_float f)
{
if (x->x_atom.a_type == A_FLOAT && f == x->x_atom.a_w.w_float)
......@@ -495,6 +502,7 @@ void select_setup(void)
0, 0, sizeof(t_sel1_proxy), 0, 0);
class_addfloat(sel1_proxy_class, (t_method)sel1_proxy_float);
class_addsymbol(sel1_proxy_class, (t_method)sel1_proxy_symbol);
class_addanything(sel1_proxy_class, (t_method)sel1_proxy_anything);
sel1_class = class_new(gensym("select"), 0, 0,
sizeof(t_sel1), 0, 0);
class_addfloat(sel1_class, sel1_float);
......
Markdown is supported
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