|
From: | Rik |
Subject: | Re: option for enabling/disabling auto-suggest feature |
Date: | Wed, 2 May 2018 09:04:55 -0700 |
On 05/02/2018 05:55 AM, Sudeepam Pandey
wrote:
I would suggest using getpref()/setpref() for the time being. For the namespace, use "Octave". For the actual name of the preference, maybe something like "autosuggest". In this case, your code can use getpref to check whether the value is boolean true before continuing. For the time being you don't even need to write an m-file to enable/disable the option. You can just use setpref directly. Later on, you could wrap setpref() in an m-file to give it a nice interface. The file to inspect is libinterp/corefcn/graphics.cc. grep -n error graphics.cc | grep property 74: error ("set: invalid value for %s property", pname.c_str ()); 104: error ("%s: unknown %s property %s", 116: error ("%s: ambiguous %s property name %s; possible matches:\n\n%s", 1312: error (R"(invalid value for color property "%s")", 1346: error (e, R"(invalid value for color property "%s" (value = %s))", 1356: error (R"(invalid value for color property "%s")", 1369: error (R"(invalid value for color property "%s")", 1384: error (R"(invalid value for double_radio property "%s")", 1411: error (R"(invalid value for double_radio property "%s")", 1657: error (R"(set: invalid graphics handle (= %g) for property "%s")", 1660: error (R"(set: invalid graphics object type for property "%s")", 1851: error ("addproperty: missing possible values for radio property"); 1913: error ("addproperty: unsupported type for dynamic property (= %s)", 1937: error ("addproperty: invalid object type (= %s)", 2194: error ("invalid %s property '%s'", pfx.c_str (), pname.c_str ()); 2219: error ("invalid default property specification"); 3069: error (e, "error setting default property %s", pname.c_str ()); 3098: error (R"(get: unknown property "%s")", pname.c_str ()); 3141: error (R"(set: unknown property "%s")", pname.c_str ()); 3157: error (R"(get_property: unknown property "%s")", pname.c_str ()); 5031: error ("set: expecting text graphics object or character string for %s property, found %s", 10885: error ("set: unknown property"); 11115: error ("__go_%s__: missing value for parent property", 11988: error ("addproperty: invalid graphics object (= %g)", h); 11995: error ("addproperty: a '%s' property already exists in the graphics object", Only the error statements which deal with an unknown property would need modification. I think the idea would be to intercept the error call about an unknown property. At each point you would first check for missing_property_hook(). If it was empty then error out in the same way as before. Otherwise, call the function provided in missing property hook and then call error() with whatever text was returned from the suggestions. Note, that this would just give you suggestions, it would not necessarily be possible to print a menu and have the user decide which one they wanted to change the text to.
If you implement it the way I suggested then the two functions are at different levels of parsing and missing_function_hook would take precedence over missing_property_hook.
|
[Prev in Thread] | Current Thread | [Next in Thread] |