tv_info.erl
来自「OTP是开放电信平台的简称」· ERL 代码 · 共 878 行 · 第 1/2 页
ERL
878 行
{fg, {0, 0, 0}}, {hscroll, bottom}, {vscroll, right}, {selectmode, single}, {click, true}, {doubleclick, true}, {data, listbox} ]), IndexId = gs:listbox(CardId, [{width, ListboxWidth}, {height, ListboxHeight}, {x, RXpos}, {y, Ypos + LabelHeight - 3}, {bg, {255, 255, 255}}, {fg, {0, 0, 0}}, {hscroll, bottom}, {vscroll, right}, {selectmode, single}, {click, true}, {doubleclick, true}, {data, listbox} ]), {{listbox, AttributesId}, {listbox, IndexId} };create_special_fields(mnesia, storage_card, CardId) -> LabelWidth = 155, LabelHeight = 24, ListboxHeight = 80, ListboxWidth = 170, VerticalSpacing = 20, LXpos = 10, MXpos = 197, RXpos = 385, % Y-positions for upper and lower row. UYpos = 40 + (LabelHeight + VerticalSpacing) * 2, LYpos = UYpos + ListboxHeight + 37, gs:label(CardId, [{width, LabelWidth}, {height, LabelHeight}, {x, LXpos}, {y, UYpos}, {bg, ?DEFAULT_BG_COLOR}, {fg, {0, 0, 0}}, {align, center}, {label, {text, "Disc Copy Nodes:"}} ]), gs:label(CardId, [{width, LabelWidth}, {height, LabelHeight}, {x, MXpos}, {y, UYpos}, {bg, ?DEFAULT_BG_COLOR}, {fg, {0, 0, 0}}, {align, center}, {label, {text, "Disc Only Copy Nodes:"}} ]), gs:label(CardId, [{width, LabelWidth}, {height, LabelHeight}, {x, RXpos}, {y, UYpos}, {bg, ?DEFAULT_BG_COLOR}, {fg, {0, 0, 0}}, {align, center}, {label, {text, "RAM Copy Nodes:"}} ]), gs:label(CardId, [{width, LabelWidth}, {height, LabelHeight}, {x, LXpos}, {y, LYpos}, {bg, ?DEFAULT_BG_COLOR}, {fg, {0, 0, 0}}, {align, center}, {label, {text, "Table Replica Nodes:"}} ]), gs:label(CardId, [{width, LabelWidth}, {height, LabelHeight}, {x, MXpos}, {y, LYpos}, {bg, ?DEFAULT_BG_COLOR}, {fg, {0, 0, 0}}, {align, center}, {label, {text, "Active Checkpoints:"}} ]), DiscCopiesId = gs:listbox(CardId, [{width, ListboxWidth}, {height, ListboxHeight}, {x, LXpos}, {y, UYpos + LabelHeight - 3}, {bg, {255, 255, 255}}, {fg, {0, 0, 0}}, {hscroll, bottom}, {vscroll, right}, {selectmode, single}, {click, true}, {doubleclick, true}, {data, listbox} ]), DiscCopiesOnlyId = gs:listbox(CardId, [{width, ListboxWidth}, {height, ListboxHeight}, {x, MXpos}, {y, UYpos + LabelHeight - 3}, {bg, {255, 255, 255}}, {fg, {0, 0, 0}}, {hscroll, bottom}, {vscroll, right}, {selectmode, single}, {click, true}, {doubleclick, true}, {data, listbox} ]), RamCopiesId = gs:listbox(CardId, [{width, ListboxWidth}, {height, ListboxHeight}, {x, RXpos}, {y, UYpos + LabelHeight - 3}, {bg, {255, 255, 255}}, {fg, {0, 0, 0}}, {hscroll, bottom}, {vscroll, right}, {selectmode, single}, {click, true}, {doubleclick, true}, {data, listbox} ]), WhereToWriteId = gs:listbox(CardId, [{width, ListboxWidth}, {height, ListboxHeight}, {x, LXpos}, {y, LYpos + LabelHeight - 3}, {bg, {255, 255, 255}}, {fg, {0, 0, 0}}, {hscroll, bottom}, {vscroll, right}, {selectmode, single}, {click, true}, {doubleclick, true}, {data, listbox} ]), CheckpointsId = gs:listbox(CardId, [{width, ListboxWidth}, {height, ListboxHeight}, {x, MXpos}, {y, LYpos + LabelHeight - 3}, {bg, {255, 255, 255}}, {fg, {0, 0, 0}}, {hscroll, bottom}, {vscroll, right}, {selectmode, single}, {click, true}, {doubleclick, true}, {data, listbox} ]), {{listbox, DiscCopiesId}, {listbox, DiscCopiesOnlyId}, {listbox, RamCopiesId}, {listbox, WhereToWriteId}, {listbox, CheckpointsId} }.create_card_data_field(N, ParentId) -> Width = 345, Height = 24, VerticalSpacing = 20, Xpos = 210, Ypos = 40 + (Height + VerticalSpacing) * (N - 1), BgFrame = gs:frame(ParentId, [{width, Width}, {height, Height}, {x, Xpos}, {y, Ypos}, {bg, {0, 0, 0}}, {bw, 0} ]), gs:label(BgFrame, [{width, Width - 2}, {height, Height - 2}, {x, 1}, {y, 1}, {bg, {255, 255, 255}}, {fg, {0, 0, 0}}, {align, w} ]).create_card_text(N, Text, ParentId) -> LabelWidth = 205, LabelHeight = 24, VerticalSpacing = 20, Xpos = 10, Ypos = 40 + (LabelHeight + VerticalSpacing) * (N - 1), gs:label(ParentId, [{width, LabelWidth}, {height, LabelHeight}, {x, Xpos}, {y, Ypos}, {bg, ?DEFAULT_BG_COLOR}, {fg, {0, 0, 0}}, {align, w}, {label, {text, Text}} ]). create_card(ParentId, FlapId) -> CardId = gs:frame(ParentId, [{width, 570}, {height, 360}, {x, 5}, {y, 35}, {bg, ?DEFAULT_BG_COLOR}, {bw, 2} ]), FlapXpos = gs:read(FlapId, data), gs:config(FlapId, [{data, {CardId, FlapXpos}} ]), CardId. set_flap_label(ParentId, Text) -> Bw = gs:read(ParentId, bw), % It is assumed that the parent is a frame! :-) Width = gs:read(ParentId, width) - 2 * Bw - 2, Height = gs:read(ParentId, height) - 2 * Bw - 6, Xpos = 0, Ypos = 0, Data = gs:read(ParentId, data), gs:label(ParentId, [{width, Width}, {height, Height}, {x, Xpos}, {y, Ypos}, % {fg, {178, 34, 34}}, {bg, ?DEFAULT_BG_COLOR}, {fg, {0, 0, 0}}, {label, {text, Text}}, {align, center}, {buttonpress, true}, {data, Data} ]).create_flap(N, _Text, ParentId) -> Width = 120, Height = 40, Spacing = 2, FirstXpos = 5, Xpos = FirstXpos + ((Width + Spacing) * (N - 1)), Ypos = 5, BorderWidth = 2, gs:frame(ParentId, [{width, Width}, {height, Height}, {x, Xpos}, {y, Ypos}, {bg, ?DEFAULT_BG_COLOR}, {bw, BorderWidth}, {cursor, hand}, {buttonpress, true}, {data, Xpos + BorderWidth} ]). update_info_flaps(TabType, Node, LocalNode, TabId, CardIds, MasterPid) -> case catch print_info(TabType, Node, LocalNode, TabId, CardIds) of {ok, TabName} -> WinTitle = tv_pc_menu_handling:get_window_title(TabType,Node,TabId,TabName), gs:config(win, [{title, "[TV] " ++ WinTitle}]), done; nodedown -> nodedown; no_table -> gs:config(win, [beep]), case get(error_msg_mode) of normal -> Msg = ["The table " ++ lists:flatten(io_lib:write(TabId)) ++ " on node", lists:flatten(io_lib:write(Node)) ++ " no longer exists!"], tv_utils:notify(win, "TV Notification", Msg); haiku -> Msg = ["Three things are certain:", "Death, taxes, and lost tables.", "Guess which has occurred."], tv_utils:notify(win, "TV Notification", Msg) end, MasterPid ! #ip_dead_table{sender = self()}; mnesia_not_started -> gs:config(win, [beep]), case get(error_msg_mode) of normal -> Msg = ["The table " ++ lists:flatten(io_lib:write(TabId)) ++ " on node", lists:flatten(io_lib:write(Node)) ++ " no longer exists!"], tv_utils:notify(win, "TV Notification", Msg); haiku -> Msg = ["A table that big?", "It might be very useful.", "But now it is gone."], tv_utils:notify(win, "TV Notification", Msg) end, MasterPid ! #ip_dead_table{sender = self()}; {unexpected_error,Reason} -> io:format("Unexpected error: ~p~n", [Reason]); _Other -> io:format("Unexpected return value: ~p~n", [_Other]), done end. loop(CardIds, MaskLabel, Node, LocalNode, TabId, TabType) -> receive #info_update_table_info{sender = Sender} -> NewNode = check_node(Node, LocalNode), update_info_flaps(TabType, NewNode, LocalNode, TabId, CardIds, Sender), loop(CardIds, MaskLabel, NewNode, LocalNode, TabId, TabType); #info_raise_window{sender = Sender} -> gs:config(CardIds#card_field_ids.window_id, [raise]), NewNode = check_node(Node, LocalNode), chk(update_info_flaps(TabType, NewNode, LocalNode, TabId, CardIds, Sender)), loop(CardIds, MaskLabel, NewNode, LocalNode, TabId, TabType); #info_quit{} -> exit(normal); {gs, _FlapId, buttonpress, {CardId, Xpos}, [1 | _]} -> gs:config(CardId, [raise ]), gs:config(MaskLabel, [raise, {x, Xpos} ]), loop(CardIds, MaskLabel, Node, LocalNode, TabId, TabType); {gs, _Id, buttonpress, {_CardId, _Xpos}, _Args} -> loop(CardIds, MaskLabel, Node, LocalNode, TabId, TabType); {gs, _LblId, enter, _Data, _Args} -> loop(CardIds, MaskLabel, Node, LocalNode, TabId, TabType); {gs, WinId, configure, _Data, _Args} -> gs:config(WinId, [{width, ?WINDOW_WIDTH}, {height, ?WINDOW_HEIGHT} ]), loop(CardIds, MaskLabel, Node, LocalNode, TabId, TabType); {gs, ListboxId, click, listbox, _Args} -> gs:config(ListboxId, [{selection, clear}]), loop(CardIds, MaskLabel, Node, LocalNode, TabId, TabType); {gs, ListboxId, doubleclick, listbox, _Args} -> gs:config(ListboxId, [{selection, clear}]), loop(CardIds, MaskLabel, Node, LocalNode, TabId, TabType); {gs, _Id, click, update, _Args} -> NewNode = check_node(Node, LocalNode), chk(update_info_flaps(TabType,NewNode,LocalNode,TabId,CardIds, CardIds#card_field_ids.parent_pid)), loop(CardIds, MaskLabel, NewNode, LocalNode, TabId, TabType); {gs, _Id, keypress, _, [r, _, 0, 1 | _]} -> NewNode = check_node(Node, LocalNode), chk(update_info_flaps(TabType,NewNode,LocalNode,TabId,CardIds, CardIds#card_field_ids.parent_pid)), loop(CardIds, MaskLabel, NewNode, LocalNode, TabId, TabType); {gs, _Id, keypress, _, ['R', _, 1, 1 | _]} -> NewNode = check_node(Node, LocalNode), chk(update_info_flaps(TabType,NewNode,LocalNode,TabId,CardIds, CardIds#card_field_ids.parent_pid)), loop(CardIds, MaskLabel, NewNode, LocalNode, TabId, TabType); {gs, _Id, click, close_menu, _Args} -> exit(normal); {gs, _Id, keypress, _, [c, _, 0, 1 | _]} -> exit(normal); {gs, _Id, keypress, _, ['C', _, 1, 1 | _]} -> exit(normal); {gs, _Id, destroy, _Data, _Args} -> exit(normal); {'EXIT', _Pid, _Reason} -> exit(normal); {error_msg_mode, Mode} -> put(error_msg_mode, Mode), loop(CardIds, MaskLabel, Node, LocalNode, TabId, TabType); _Other -> loop(CardIds, MaskLabel, Node, LocalNode, TabId, TabType) end. chk(nodedown) -> gs:config(win, [beep]), case get(error_msg_mode) of normal -> tv_utils:notify(win, "TV Notification", ["The node is down, and the", "table cannot be reached."]); haiku -> ErrMsg1 = ["With searching comes loss", "And the presence of absence:", "Node is down."], tv_utils:notify(win, "TV Notification", ErrMsg1) end;chk(_Other) -> done.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?