diff options
-rw-r--r-- | lib/observer/src/observer_procinfo.erl | 76 | ||||
-rw-r--r-- | lib/observer/src/observer_wx.erl | 21 |
2 files changed, 57 insertions, 40 deletions
diff --git a/lib/observer/src/observer_procinfo.erl b/lib/observer/src/observer_procinfo.erl index 127599a39e..a4c5914c49 100644 --- a/lib/observer/src/observer_procinfo.erl +++ b/lib/observer/src/observer_procinfo.erl @@ -41,7 +41,7 @@ -record(worker, {panel, callback}). start(Process, ParentFrame, Parent) -> - wx_object:start(?MODULE, [Process, ParentFrame, Parent], []). + wx_object:start_link(?MODULE, [Process, ParentFrame, Parent], []). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -52,7 +52,7 @@ init([Pid, ParentFrame, Parent]) -> {registered_name, Registered} -> atom_to_list(Registered) end, Frame=wxFrame:new(ParentFrame, ?wxID_ANY, [atom_to_list(node(Pid)), $:, Title], - [{style, ?wxDEFAULT_FRAME_STYLE}, {size, {800,700}}]), + [{style, ?wxDEFAULT_FRAME_STYLE}, {size, {850,600}}]), MenuBar = wxMenuBar:new(), create_menus(MenuBar), wxFrame:setMenuBar(Frame, MenuBar), @@ -75,10 +75,7 @@ init([Pid, ParentFrame, Parent]) -> }} catch error:{badrpc, _} -> observer_wx:return_to_localnode(ParentFrame, node(Pid)), - {stop, badrpc, #state{parent=Parent, pid=Pid}}; - Error:Reason -> - io:format("~p:~p: ~p ~p~n ~p~n", - [?MODULE, ?LINE, Error, Reason, erlang:get_stacktrace()]) + {stop, badrpc, #state{parent=Parent, pid=Pid}} end. init_panel(Notebook, Str, Pid, Fun) -> @@ -92,30 +89,27 @@ init_panel(Notebook, Str, Pid, Fun) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Callbacks%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% handle_event(#wx{event=#wxClose{type=close_window}}, State) -> - {stop, shutdown, State}; + {stop, normal, State}; handle_event(#wx{id=?wxID_CLOSE, event=#wxCommand{type=command_menu_selected}}, State) -> - {stop, shutdown, State}; + {stop, normal, State}; handle_event(#wx{id=?REFRESH}, #state{pages=Pages}=State) -> [(W#worker.callback)() || W <- Pages], {noreply, State}; -handle_event(Event, State) -> - io:format("~p: ~p, Handle event: ~p~n", [?MODULE, ?LINE, Event]), - {noreply, State}. +handle_event(Event, _State) -> + error({unhandled_event, Event}). -handle_info(Info, State) -> - io:format("~p: ~p, Handle info: ~p~n", [?MODULE, ?LINE, Info]), +handle_info(_Info, State) -> + %% io:format("~p: ~p, Handle info: ~p~n", [?MODULE, ?LINE, Info]), {noreply, State}. -handle_call(Call, _From, State) -> - io:format("~p ~p: Got call ~p~n",[?MODULE, ?LINE, Call]), - {reply, ok, State}. +handle_call(Call, From, _State) -> + error({unhandled_call, Call, From}). -handle_cast(Cast, State) -> - io:format("~p ~p: Got cast ~p~n", [?MODULE, ?LINE, Cast]), - {noreply, State}. +handle_cast(Cast, _State) -> + error({unhandled_cast, Cast}). terminate(_Reason, #state{parent=Parent,pid=Pid,frame=Frame}) -> Parent ! {procinfo_menu_closed, Pid}, @@ -179,26 +173,42 @@ init_dict_page(Parent, Pid) -> {Text, Update}. init_stack_page(Parent, Pid) -> - Text = init_text_page(Parent), - Format = fun({Mod, Fun, Arg, Info}) -> - Str = io_lib:format("~w:~w/~w", [Mod,Fun,Arg]), - case Info of - [{file,File},{line,Line}] -> - io_lib:format("~-45.s ~s:~w~n", [Str,File,Line]); - _ -> - [Str,$\n] - end - end, + LCtrl = wxListCtrl:new(Parent, [{style, ?wxLC_REPORT bor ?wxLC_HRULES}]), + Li = wxListItem:new(), + wxListItem:setText(Li, "Module:Function/Arg"), + wxListCtrl:insertColumn(LCtrl, 0, Li), + wxListCtrl:setColumnWidth(LCtrl, 0, 300), + wxListItem:setText(Li, "File:LineNumber"), + wxListCtrl:insertColumn(LCtrl, 1, Li), + wxListCtrl:setColumnWidth(LCtrl, 1, 300), + wxListItem:destroy(Li), Update = fun() -> {current_stacktrace,RawBt} = observer_wx:try_rpc(node(Pid), erlang, process_info, [Pid, current_stacktrace]), - Last = wxTextCtrl:getLastPosition(Text), - wxTextCtrl:remove(Text, 0, Last), - [wxTextCtrl:writeText(Text, Format(Entry)) || Entry <- RawBt] + wxListCtrl:deleteAllItems(LCtrl), + wx:foldl(fun({M, F, A, Info}, Row) -> + _Item = wxListCtrl:insertItem(LCtrl, Row, ""), + ?EVEN(Row) andalso + wxListCtrl:setItemBackgroundColour(LCtrl, Row, ?BG_EVEN), + wxListCtrl:setItem(LCtrl, Row, 0, observer_lib:to_str({M,F,A})), + FileLine = case Info of + [{file,File},{line,Line}] -> + io_lib:format("~s:~w", [File,Line]); + _ -> + [] + end, + wxListCtrl:setItem(LCtrl, Row, 1, FileLine), + Row+1 + end, 0, RawBt) end, + Resize = fun(#wx{event=#wxSize{size={W,_}}},Ev) -> + wxEvent:skip(Ev), + observer_lib:set_listctrl_col_size(LCtrl, W) + end, + wxListCtrl:connect(LCtrl, size, [{callback, Resize}]), Update(), - {Text, Update}. + {LCtrl, Update}. create_menus(MenuBar) -> Menus = [{"File", [#create_menu{id=?wxID_CLOSE, text="Close"}]}, diff --git a/lib/observer/src/observer_wx.erl b/lib/observer/src/observer_wx.erl index 65380a49b0..5586cfcb9a 100644 --- a/lib/observer/src/observer_wx.erl +++ b/lib/observer/src/observer_wx.erl @@ -78,7 +78,7 @@ init(_Args) -> wx:new(), catch wxSystemOptions:setOption("mac.listctrl.always_use_generic", 1), Frame = wxFrame:new(wx:null(), ?wxID_ANY, "Observer", - [{size, {1000, 500}}, {style, ?wxDEFAULT_FRAME_STYLE}]), + [{size, {850, 600}}, {style, ?wxDEFAULT_FRAME_STYLE}]), IconFile = filename:join(code:priv_dir(observer), "erlang_observer.png"), Icon = wxIcon:new(IconFile, [{type,?wxBITMAP_TYPE_PNG}]), wxFrame:setIcon(Frame, Icon), @@ -155,11 +155,18 @@ setup(#state{frame = Frame} = State) -> nodes = Nodes }, %% Create resources which we don't want to duplicate - SysFont = wxSystemSettings:getFont(?wxSYS_DEFAULT_GUI_FONT), - SysFontSize = wxFont:getPointSize(SysFont), - Modern = wxFont:new(SysFontSize, ?wxFONTFAMILY_MODERN, ?wxFONTSTYLE_NORMAL, ?wxFONTWEIGHT_NORMAL), - put({font, modern}, Modern), - put({font, fixed}, Modern), + SysFont = wxSystemSettings:getFont(?wxSYS_SYSTEM_FIXED_FONT), + %% OemFont = wxSystemSettings:getFont(?wxSYS_OEM_FIXED_FONT), + %% io:format("Sz sys ~p(~p) oem ~p(~p)~n", + %% [wxFont:getPointSize(SysFont), wxFont:isFixedWidth(SysFont), + %% wxFont:getPointSize(OemFont), wxFont:isFixedWidth(OemFont)]), + Fixed = case wxFont:isFixedWidth(SysFont) of + true -> SysFont; + false -> %% Sigh + SysFontSize = wxFont:getPointSize(SysFont), + wxFont:new(SysFontSize, ?wxFONTFAMILY_MODERN, ?wxFONTSTYLE_NORMAL, ?wxFONTWEIGHT_NORMAL) + end, + put({font, fixed}, Fixed), UpdState. @@ -472,7 +479,7 @@ default_menus(NodesMenuItems) -> [#create_menu{id = ?ID_CONNECT, text = "Enable distribution"}]} end, case os:type() =:= {unix, darwin} of - false -> + false -> FileMenu = {"File", [Quit]}, HelpMenu = {"Help", [About,Help]}, [FileMenu, NodeMenu, HelpMenu]; |