aboutsummaryrefslogtreecommitdiffstats
path: root/lib/observer/src/observer_lib.erl
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2011-11-30 16:31:45 +0100
committerDan Gudmundsson <[email protected]>2011-12-02 17:07:24 +0100
commit6bbe0512b1686f06489893479ae1d14ef15d004a (patch)
tree009e16f0debb9dd2aa8532a3daa5e9705df2c343 /lib/observer/src/observer_lib.erl
parent69445197463ee031864b70f2b5618013461b2df0 (diff)
downloadotp-6bbe0512b1686f06489893479ae1d14ef15d004a.tar.gz
otp-6bbe0512b1686f06489893479ae1d14ef15d004a.tar.bz2
otp-6bbe0512b1686f06489893479ae1d14ef15d004a.zip
[observer] Added an application viewer
Diffstat (limited to 'lib/observer/src/observer_lib.erl')
-rw-r--r--lib/observer/src/observer_lib.erl25
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/observer/src/observer_lib.erl b/lib/observer/src/observer_lib.erl
index 7763e8c60a..967baa5c7a 100644
--- a/lib/observer/src/observer_lib.erl
+++ b/lib/observer/src/observer_lib.erl
@@ -19,7 +19,7 @@
-module(observer_lib).
-export([get_wx_parent/1,
- display_info_dialog/1,
+ display_info_dialog/1, user_term/3,
interval_dialog/4, start_timer/1, stop_timer/1,
display_info/2, fill_info/2, update_info/2, to_str/1,
create_menus/3, create_menu_item/3,
@@ -196,6 +196,7 @@ to_str(No) when is_integer(No) ->
to_str(Term) ->
io_lib:format("~w", [Term]).
+create_menus([], _MenuBar, _Type) -> ok;
create_menus(Menus, MenuBar, Type) ->
Add = fun({Tag, Ms}, Index) ->
create_menu(Tag, Ms, Index, MenuBar, Type)
@@ -330,3 +331,25 @@ scroll_size(LCtrl) ->
false -> 0
end
end.
+
+
+user_term(Parent, Title, Default) ->
+ Dialog = wxTextEntryDialog:new(Parent, Title, [{value, Default}]),
+ case wxTextEntryDialog:showModal(Dialog) of
+ ?wxID_OK ->
+ Str = wxTextEntryDialog:getValue(Dialog),
+ wxTextEntryDialog:destroy(Dialog),
+ parse_string(Str);
+ ?wxID_CANCEL ->
+ wxTextEntryDialog:destroy(Dialog)
+ end.
+
+parse_string(Str) ->
+ try
+ {ok, Tokens, _} = erl_scan:string(Str),
+ erl_parse:parse_term(Tokens)
+ catch _:{badmatch, {error, {_, _, Err}}} ->
+ {error, ["Parse error: ", Err]};
+ _Err ->
+ {error, ["Syntax error in: ", Str]}
+ end.