dbg_ui_mon_win.erl
来自「OTP是开放电信平台的简称」· ERL 代码 · 共 564 行 · 第 1/2 页
ERL
564 行
%% ``The contents of this file are subject to the Erlang Public License,%% Version 1.1, (the "License"); you may not use this file except in%% compliance with the License. You should have received a copy of the%% Erlang Public License along with this software. If not, it can be%% retrieved via the world wide web at http://www.erlang.org/.%% %% Software distributed under the License is distributed on an "AS IS"%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See%% the License for the specific language governing rights and limitations%% under the License.%% %% The Initial Developer of the Original Code is Ericsson Utvecklings AB.%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings%% AB. All Rights Reserved.''%% %% $Id$%%-module(dbg_ui_mon_win).%% External exports-export([init/0]).-export([create_win/3, get_window/1, show_option/3, enable/2, is_enabled/1, select/2, add_module/3, delete_module/2, add_process/6, update_process/4, clear_processes/1, add_break/3, update_break/2, delete_break/2, clear_breaks/1, clear_breaks/2, handle_event/2 ]).-define(default_rows,50).-record(moduleInfo, {module, menubtn}).-record(procInfo, {pid, row}).-record(breakInfo, {point, status, break}).-record(winInfo, {window, % gsobj() grid, % gsobj() row, % int() Last row in grid focus, % int() Selected row in grid modules=[], % [#moduleInfo{}] Known modules processes=[], % [#procInfo{}] Known processes breaks=[], % [#breakInfo{}] Known breakpoints listbox, % gsobj() Listinng known modules %% Auto attach buttons fbutton, % gsobj() bbutton, % gsobj() ebutton, % gsobj() selected=[], % ['First Call'|'On Break'|'On Exit'] slabel, % showing Stack Trace option blabel % showing Back Trace Size }).%%====================================================================%% External exports%%====================================================================init() -> dbg_ui_win:init().%%--------------------------------------------------------------------%% create_win(GS, Title, Menus) -> #winInfo{}%% GS = gsobj()%% Title = string()%% Menus = [menu()] See dbg_ui_win.erl%%---------------------------------------------------------------------define(PAD, 5).-define(Wf, 150).-define(Wg, 770).-define(W, 800).-define(H, 390).create_win(GS, Title, Menus) -> Win = gs:window(GS, [{title, Title}, {width, ?W}, {height, ?H}, {configure,true}, {destroy,true}, {keypress,true}, {motion,true}]), MenuBar = gs:menubar(Win, []), dbg_ui_win:create_menus(MenuBar, Menus), dbg_ui_winman:windows_menu(MenuBar), Font = dbg_ui_win:font(normal), Frame = gs:frame(Win, [{x, ?PAD}, {y, 30}, {width, ?Wf}, {height, ?H}]), Hlb = 200, Listbox = gs:listbox(Frame, [{x, 0}, {y, 0}, {width, ?Wf}, {height, Hlb}, {data, listbox}, {doubleclick, true}, {items, []}]), gs:label(Frame, [{x, 0}, {y, Hlb}, {width, ?Wf}, {height, 20}, {align, w}, {label, {text, "Auto Attach:"}}, {font, Font}]), Fbtn = gs:checkbutton(Frame, [{x, 0}, {y, Hlb+20}, {width, ?Wf}, {height, 20}, {label, {text, 'First Call'}}, {align, w}, {font, Font}, {data, autoattach}]), Bbtn = gs:checkbutton(Frame, [{x, 0}, {y, Hlb+40}, {width, ?Wf}, {height, 20}, {label, {text, 'On Break'}}, {align, w}, {font, Font}, {data, autoattach}]), Ebtn = gs:checkbutton(Frame, [{x, 0}, {y, Hlb+60}, {width, ?Wf}, {height, 20}, {label, {text, 'On Exit'}}, {align, w}, {font, Font}, {data, autoattach}]), SLabel = gs:label(Frame, [{x, 0}, {y, Hlb+80}, {width, ?Wf}, {height, 40}, {font, Font}, {align, w}]), BLabel = gs:label(Frame, [{x, 0}, {y, Hlb+120}, {width, ?Wf}, {height, 40}, {font, Font}, {align, w}]), Grid = gs:grid(Win, [{x, 2*?PAD+?Wf}, {y, 30}, {width, ?W-(2*?PAD+?Wf)}, {height, ?H-30}, {bg, grey}, {fg, black}, {vscroll, right}, {hscroll, bottom}, calc_columnwidths(?Wg), {rows, {1,?default_rows}}]), gs:gridline(Grid, [{row, 1}, {bw, 5}, {fg, blue}, {font, Font}, {text, {1,"Pid"}}, {text, {2,"Initial Call"}}, {text, {3,"Name"}}, {text, {4,"Status"}}, {text, {5,"Information"}}]), gs:config(Win, {map, true}), #winInfo{window=Win, grid=Grid, row=1, focus=0, listbox=Listbox, fbutton=Fbtn, bbutton=Bbtn, ebutton=Ebtn, slabel=SLabel, blabel=BLabel}.%%--------------------------------------------------------------------%% get_window(WinInfo) -> Window%% WinInfo = #winInfo{}%% Window = gsobj()%%--------------------------------------------------------------------get_window(WinInfo) -> WinInfo#winInfo.window.%%--------------------------------------------------------------------%% show_option(WinInfo, Option, Value) -> void()%% WinInfo = #winInfo{}%% Option = auto_attach | stack_trace | back_trace%% Value = [Flag] % Option==auto_attach%% Flag = init | break | exit%% | true | all | no_tail | false % Option==stack_trace%% | int() % Option==back_trace%%--------------------------------------------------------------------show_option(WinInfo, Option, Value) -> case Option of auto_attach -> lists:foreach(fun (Button) -> gs:config(Button, {select, false}) end, option_buttons(WinInfo, [init, break, exit])), lists:foreach(fun (Button) -> gs:config(Button, {select, true}) end, option_buttons(WinInfo, Value)); stack_trace -> Text = case Value of all -> "Stack Trace:\n On (with tail)"; true -> "Stack Trace:\n On (with tail)"; no_tail -> "Stack Trace:\n On (no tail)"; false -> "Stack Trace:\n Off" end, gs:config(WinInfo#winInfo.slabel, {label, {text, Text}}); back_trace -> Text = "Back Trace Size:\n " ++ integer_to_list(Value), gs:config(WinInfo#winInfo.blabel, {label, {text, Text}}) end.option_buttons(WinInfo, [init|Flags]) -> [WinInfo#winInfo.fbutton|option_buttons(WinInfo, Flags)];option_buttons(WinInfo, [break|Flags]) -> [WinInfo#winInfo.bbutton|option_buttons(WinInfo, Flags)];option_buttons(WinInfo, [exit|Flags]) -> [WinInfo#winInfo.ebutton|option_buttons(WinInfo, Flags)];option_buttons(_WinInfo, []) -> [].%%--------------------------------------------------------------------%% enable([MenuItem], Bool)%% is_enabled(MenuItem) -> Bool%% MenuItem = atom()%% Bool = boolean()%%--------------------------------------------------------------------enable(MenuItems, Bool) -> lists:foreach(fun(MenuItem) -> gs:config(MenuItem, {enable, Bool}) end, MenuItems).is_enabled(MenuItem) -> gs:read(MenuItem, enable).%%--------------------------------------------------------------------%% select(MenuItem, Bool)%% MenuItem = atom()%% Bool = boolean()%%--------------------------------------------------------------------select(MenuItem, Bool) -> dbg_ui_win:select(MenuItem, Bool).%%--------------------------------------------------------------------%% add_module(WinInfo, Name, Mod) -> WinInfo%% WinInfo = #winInfo{}%% Name = atom()%% Mod = atom()%%--------------------------------------------------------------------add_module(WinInfo, Menu, Mod) -> Modules = WinInfo#winInfo.modules, case lists:keysearch(Mod, #moduleInfo.module, Modules) of {value, _ModInfo} -> WinInfo; false -> %% Create a menu for the module Font = dbg_ui_win:font(normal), MenuBtn = gs:menuitem(Menu, [{label, {text,Mod}}, {font, Font}, {itemtype, cascade}]), SubMenu = gs:menu(MenuBtn, []), gs:menuitem(SubMenu, [{label, {text,"View"}}, {font, Font}, {data, {module,Mod,view}}]), gs:menuitem(SubMenu, [{label, {text,"Delete"}}, {font, Font}, {data, {module,Mod,delete}}]), %% Add the module to the listbox gs:config(WinInfo#winInfo.listbox, {add, Mod}), ModInfo = #moduleInfo{module=Mod, menubtn=MenuBtn}, WinInfo#winInfo{modules=[ModInfo | Modules]} end. %%--------------------------------------------------------------------%% delete_module(WinInfo, Mod) -> WinInfo%% WinInfo = #winInfo{}%% Mod = atom()%%--------------------------------------------------------------------delete_module(WinInfo, Mod) -> {value, ModInfo} = lists:keysearch(Mod, #moduleInfo.module, WinInfo#winInfo.modules), gs:destroy(ModInfo#moduleInfo.menubtn), delete_module(WinInfo#winInfo.listbox, atom_to_list(Mod), 0), WinInfo#winInfo{modules=lists:keydelete(Mod, #moduleInfo.module, WinInfo#winInfo.modules)}.delete_module(Listbox, ModS, Index) -> case gs:read(Listbox, {get, Index}) of ModS -> gs:config(Listbox, {del, Index}); _OtherModS -> delete_module(Listbox, ModS, Index+1) end.%%--------------------------------------------------------------------%% add_process(WinInfo, Pid, Name, Function, Status, Info) -> WinInfo%% WinInfo = #winInfo{}%% Pid = pid()%% Name = undefined | atom()%% Function = {Mod, Func, Args}%% Status = idle | running | break | exit%% Info = {} | term()%%--------------------------------------------------------------------add_process(WinInfo, Pid, Name, {Mod,Func,Args}, Status, Info) -> Grid = WinInfo#winInfo.grid, Row = (WinInfo#winInfo.row)+1, GridLine = case gs:read(Grid, {obj_at_row, Row}) of
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?