summaryrefslogtreecommitdiff
path: root/lib/observer/src/observer_lib.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/observer/src/observer_lib.erl')
-rw-r--r--lib/observer/src/observer_lib.erl82
1 files changed, 49 insertions, 33 deletions
diff --git a/lib/observer/src/observer_lib.erl b/lib/observer/src/observer_lib.erl
index 57a9a741a5..c2cc61af86 100644
--- a/lib/observer/src/observer_lib.erl
+++ b/lib/observer/src/observer_lib.erl
@@ -26,7 +26,9 @@
wait_for_progress/0, report_progress/1,
user_term/3, user_term_multiline/3,
interval_dialog/4, start_timer/1, start_timer/2, stop_timer/1, timer_config/1,
- display_info/2, display_info/3, fill_info/2, update_info/2, to_str/1,
+ display_info/2, display_info/3,
+ fill_info/2, fill_info/3, update_info/2,
+ to_str/1,
create_menus/3, create_menu_item/3,
is_darkmode/1, colors/1, create_attrs/1,
set_listctrl_col_size/2, mix/3,
@@ -171,51 +173,65 @@ display_info(Panel, Sizer, Info) ->
end,
[Add(I) || I <- Info].
-fill_info([{dynamic, Key}|Rest], Data)
+fill_info(Fields, Data) ->
+ fill_info(Fields, Data, undefined).
+
+fill_info([{dynamic, Key}|Rest], Data, Default)
when is_atom(Key); is_function(Key) ->
%% Special case used by crashdump_viewer when the value decides
%% which header to use
- case get_value(Key, Data) of
- undefined -> [undefined | fill_info(Rest, Data)];
- {Str,Value} -> [{Str, Value} | fill_info(Rest, Data)]
+ case get_value(Key, Data, Default) of
+ undefined -> [undefined | fill_info(Rest, Data, Default)];
+ {Str,Value} -> [{Str, Value} | fill_info(Rest, Data, Default)]
end;
-fill_info([{Str, Key}|Rest], Data) when is_atom(Key); is_function(Key) ->
- case get_value(Key, Data) of
- undefined -> [undefined | fill_info(Rest, Data)];
- Value -> [{Str, Value} | fill_info(Rest, Data)]
+fill_info([{Str, Key}|Rest], Data, Default)
+ when is_atom(Key); is_function(Key) ->
+ case get_value(Key, Data, Default) of
+ undefined ->
+ [undefined | fill_info(Rest, Data, Default)];
+ Value ->
+ [{Str, Value} | fill_info(Rest, Data, Default)]
end;
-fill_info([{Str,Attrib,Key}|Rest], Data) when is_atom(Key); is_function(Key) ->
- case get_value(Key, Data) of
- undefined -> [undefined | fill_info(Rest, Data)];
- Value -> [{Str,Attrib,Value} | fill_info(Rest, Data)]
+fill_info([{Str, Attrib, Key}|Rest], Data, Default)
+ when is_atom(Key); is_function(Key) ->
+ case get_value(Key, Data, Default) of
+ undefined ->
+ [undefined | fill_info(Rest, Data, Default)];
+ Value ->
+ [{Str,Attrib,Value} | fill_info(Rest, Data, Default)]
end;
-fill_info([{Str, {Format, Key}}|Rest], Data)
+fill_info([{Str, {Format, Key}}|Rest], Data, Default)
when is_atom(Key); is_function(Key) ->
- case get_value(Key, Data) of
- undefined -> [undefined | fill_info(Rest, Data)];
- Value -> [{Str, {Format, Value}} | fill_info(Rest, Data)]
+ case get_value(Key, Data, Default) of
+ undefined -> [undefined | fill_info(Rest, Data, Default)];
+ Value -> [{Str, {Format, Value}} | fill_info(Rest, Data, Default)]
end;
-fill_info([{Str, Attrib, {Format, Key}}|Rest], Data)
+fill_info([{Str, Attrib, {Format, Key}}|Rest], Data, Default)
when is_atom(Key); is_function(Key) ->
- case get_value(Key, Data) of
- undefined -> [undefined | fill_info(Rest, Data)];
- Value -> [{Str, Attrib, {Format, Value}} | fill_info(Rest, Data)]
+ case get_value(Key, Data, Default) of
+ undefined -> [undefined | fill_info(Rest, Data, Default)];
+ Value -> [{Str, Attrib, {Format, Value}} |
+ fill_info(Rest, Data, Default)]
end;
-fill_info([{Str,SubStructure}|Rest], Data) when is_list(SubStructure) ->
- [{Str, fill_info(SubStructure, Data)}|fill_info(Rest,Data)];
-fill_info([{Str,Attrib,SubStructure}|Rest], Data) ->
- [{Str, Attrib, fill_info(SubStructure, Data)}|fill_info(Rest,Data)];
-fill_info([{Str, Key = {K,N}}|Rest], Data) when is_atom(K), is_integer(N) ->
- case get_value(Key, Data) of
- undefined -> [undefined | fill_info(Rest, Data)];
- Value -> [{Str, Value} | fill_info(Rest, Data)]
+fill_info([{Str,SubStructure}|Rest], Data, Default)
+ when is_list(SubStructure) ->
+ [{Str, fill_info(SubStructure, Data, Default)}|
+ fill_info(Rest, Data, Default)];
+fill_info([{Str,Attrib,SubStructure}|Rest], Data, Default) ->
+ [{Str, Attrib, fill_info(SubStructure, Data, Default)}|
+ fill_info(Rest, Data, Default)];
+fill_info([{Str, Key = {K,N}}|Rest], Data, Default)
+ when is_atom(K), is_integer(N) ->
+ case get_value(Key, Data, Default) of
+ undefined -> [undefined | fill_info(Rest, Data, Default)];
+ Value -> [{Str, Value} | fill_info(Rest, Data, Default)]
end;
-fill_info([], _) -> [].
+fill_info([], _, _Default) -> [].
-get_value(Fun, Data) when is_function(Fun) ->
+get_value(Fun, Data, _Default) when is_function(Fun) ->
Fun(Data);
-get_value(Key, Data) ->
- proplists:get_value(Key,Data).
+get_value(Key, Data, Default) ->
+ proplists:get_value(Key, Data, Default).
update_info([Fields|Fs], [{_Header, SubStructure}| Rest]) ->
update_info2(Fields, SubStructure),