Make Contract Calls Great Again #35
+7
-4
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
-include_lib("wx/include/wx.hrl").
|
-include_lib("wx/include/wx.hrl").
|
||||||
-export([is_int/1,
|
-export([is_int/1,
|
||||||
mono_text/2, mono_text/3,
|
mono_text/2, mono_text/3, mono_text/4,
|
||||||
button/2, button/3,
|
button/2, button/3,
|
||||||
copy_to_clipboard/1]).
|
copy_to_clipboard/1]).
|
||||||
|
|
||||||
@@ -50,14 +50,17 @@ mono_text(Parent, Name) ->
|
|||||||
%% notion of text styling).
|
%% notion of text styling).
|
||||||
|
|
||||||
mono_text(Parent, Name, Value) ->
|
mono_text(Parent, Name, Value) ->
|
||||||
Text = wxStaticText:new(Parent, ?wxID_ANY, Value),
|
mono_text(Parent, Name, Value, []).
|
||||||
|
|
||||||
|
mono_text(Parent, Name, Value, Options) ->
|
||||||
|
Text = wxTextCtrl:new(Parent, ?wxID_ANY, [{value, Value} | Options]),
|
||||||
Font = wxFont:new(10, ?wxFONTFAMILY_TELETYPE, ?wxFONTSTYLE_NORMAL, ?wxFONTWEIGHT_NORMAL),
|
Font = wxFont:new(10, ?wxFONTFAMILY_TELETYPE, ?wxFONTSTYLE_NORMAL, ?wxFONTWEIGHT_NORMAL),
|
||||||
ok =
|
ok =
|
||||||
case wxStaticText:setFont(Text, Font) of
|
case wxTextCtrl:setFont(Text, Font) of
|
||||||
true -> ok;
|
true -> ok;
|
||||||
false -> tell(info, "wxStaticText ~p is already monospace.", [Text])
|
false -> tell(info, "wxStaticText ~p is already monospace.", [Text])
|
||||||
end,
|
end,
|
||||||
#w{name = Name, id = wxStaticText:getId(Text), wx = Text}.
|
#w{name = Name, id = wxTextCtrl:getId(Text), wx = Text}.
|
||||||
|
|
||||||
|
|
||||||
-spec button(Parent, Label) -> Button
|
-spec button(Parent, Label) -> Button
|
||||||
|
|||||||
+40
-28
@@ -96,18 +96,21 @@ init({Prefs, FunDef = {FunName, FunType}, ConID, Build, Selected, Keys}) ->
|
|||||||
ok = wxChoice:setSelection(KeyPicker, ZeroBasedSelected),
|
ok = wxChoice:setSelection(KeyPicker, ZeroBasedSelected),
|
||||||
_ = wxStaticBoxSizer:add(KeySz, KeyPicker, zxw:flags(wide)),
|
_ = wxStaticBoxSizer:add(KeySz, KeyPicker, zxw:flags(wide)),
|
||||||
|
|
||||||
{ArgSz, Args, Dimensions} = call_arg_sizer(Frame, J, FunSpec),
|
{ArgSz, Args, HasArgs} = call_arg_sizer(Frame, J, FunSpec),
|
||||||
{ParamSz, Params} = call_param_sizer(Frame, J),
|
{ParamSz, Params} = call_param_sizer(Frame, J),
|
||||||
|
|
||||||
Action = #w{wx = ActionBn} = gd_lib:button(Frame, ActionLabel),
|
Action = #w{wx = ActionBn} = gd_lib:button(Frame, ActionLabel),
|
||||||
|
|
||||||
TX_Sz = wxStaticBoxSizer:new(?wxVERTICAL, Frame, [{label, J("Transaction Info")}]),
|
TX_Sz = wxStaticBoxSizer:new(?wxVERTICAL, Frame, [{label, J("Transaction Info")}]),
|
||||||
TX_Sz_Box = wxStaticBoxSizer:getStaticBox(TX_Sz),
|
TX_Sz_Box = wxStaticBoxSizer:getStaticBox(TX_Sz),
|
||||||
TX_Data = #w{wx = DataT} = gd_lib:mono_text(TX_Sz_Box, tx_hash),
|
TxStyle = [{style, ?wxTE_READONLY}],
|
||||||
TX_Hash = #w{wx = HashT} = gd_lib:mono_text(TX_Sz_Box, tx_hash),
|
TX_Data = #w{wx = DataT} = gd_lib:mono_text(TX_Sz_Box, tx_data, "", TxStyle),
|
||||||
TX_Info = #w{wx = InfoT} = gd_lib:mono_text(TX_Sz_Box, tx_hash),
|
TX_Hash = #w{wx = HashT} = gd_lib:mono_text(TX_Sz_Box, tx_hash, "", TxStyle),
|
||||||
|
TX_Info = #w{wx = InfoT} = gd_lib:mono_text(TX_Sz_Box, tx_info, "", TxStyle),
|
||||||
|
|
||||||
Line = wxStaticLine:new(TX_Sz_Box, [{style, ?wxLI_HORIZONTAL}]),
|
Line = wxStaticLine:new(TX_Sz_Box, [{style, ?wxLI_HORIZONTAL}]),
|
||||||
Out = #w{wx = OutTxt} = gd_lib:mono_text(TX_Sz_Box, out),
|
OutStyle = [{style, ?wxTE_MULTILINE bor ?wxTE_READONLY}],
|
||||||
|
Out = #w{wx = OutTxt} = gd_lib:mono_text(TX_Sz_Box, out, "", OutStyle),
|
||||||
Copy = #w{wx = CopyBn} = gd_lib:button(TX_Sz_Box, J("Copy")),
|
Copy = #w{wx = CopyBn} = gd_lib:button(TX_Sz_Box, J("Copy")),
|
||||||
|
|
||||||
_ = wxStaticBoxSizer:add(TX_Sz, DataT, zxw:flags({base, 5})),
|
_ = wxStaticBoxSizer:add(TX_Sz, DataT, zxw:flags({base, 5})),
|
||||||
@@ -117,14 +120,19 @@ init({Prefs, FunDef = {FunName, FunType}, ConID, Build, Selected, Keys}) ->
|
|||||||
_ = wxStaticBoxSizer:add(TX_Sz, OutTxt, zxw:flags({wide, 5})),
|
_ = wxStaticBoxSizer:add(TX_Sz, OutTxt, zxw:flags({wide, 5})),
|
||||||
_ = wxStaticBoxSizer:add(TX_Sz, CopyBn, zxw:flags({base, 5})),
|
_ = wxStaticBoxSizer:add(TX_Sz, CopyBn, zxw:flags({base, 5})),
|
||||||
|
|
||||||
_ = wxSizer:add(MainSz, ArgSz, zxw:flags({wide, 5})),
|
ArgSzArgs =
|
||||||
|
case HasArgs of
|
||||||
|
true -> {wide, 5};
|
||||||
|
false -> {base, 5}
|
||||||
|
end,
|
||||||
|
_ = wxSizer:add(MainSz, ArgSz, zxw:flags(ArgSzArgs)),
|
||||||
_ = wxSizer:add(MainSz, KeySz, zxw:flags({base, 5})),
|
_ = wxSizer:add(MainSz, KeySz, zxw:flags({base, 5})),
|
||||||
_ = wxSizer:add(MainSz, ParamSz, zxw:flags({base, 5})),
|
_ = wxSizer:add(MainSz, ParamSz, zxw:flags({base, 5})),
|
||||||
_ = wxSizer:add(MainSz, ActionBn, zxw:flags({base, 5})),
|
_ = wxSizer:add(MainSz, ActionBn, zxw:flags({base, 5})),
|
||||||
_ = wxSizer:add(MainSz, TX_Sz, zxw:flags({base, 5})),
|
_ = wxSizer:add(MainSz, TX_Sz, zxw:flags({wide, 5})),
|
||||||
|
|
||||||
_ = wxFrame:setSizer(Frame, MainSz),
|
_ = wxFrame:setSizer(Frame, MainSz),
|
||||||
_ = wxFrame:setSize(Frame, Dimensions),
|
_ = wxFrame:setSize(Frame, {900, 900}),
|
||||||
_ = wxSizer:layout(MainSz),
|
_ = wxSizer:layout(MainSz),
|
||||||
ok = wxFrame:connect(Frame, close_window),
|
ok = wxFrame:connect(Frame, close_window),
|
||||||
ok = wxFrame:connect(Frame, command_button_clicked),
|
ok = wxFrame:connect(Frame, command_button_clicked),
|
||||||
@@ -141,17 +149,17 @@ init({Prefs, FunDef = {FunName, FunType}, ConID, Build, Selected, Keys}) ->
|
|||||||
|
|
||||||
call_arg_sizer(Frame, J, {CallArgs, ReturnType}) ->
|
call_arg_sizer(Frame, J, {CallArgs, ReturnType}) ->
|
||||||
SpecSz = wxStaticBoxSizer:new(?wxVERTICAL, Frame, [{label, J("Function Spec")}]),
|
SpecSz = wxStaticBoxSizer:new(?wxVERTICAL, Frame, [{label, J("Function Spec")}]),
|
||||||
{CallSz, CallControls, Dimensions} = call_sizer(Frame, J, CallArgs),
|
{CallSz, CallControls, HasArgs} = call_sizer(Frame, J, CallArgs),
|
||||||
ReturnSz = return_sizer(Frame, J, ReturnType),
|
ReturnSz = return_sizer(Frame, J, ReturnType),
|
||||||
_ = wxStaticBoxSizer:add(SpecSz, CallSz, zxw:flags({wide, 5})),
|
_ = wxStaticBoxSizer:add(SpecSz, CallSz, zxw:flags({wide, 5})),
|
||||||
_ = wxStaticBoxSizer:add(SpecSz, ReturnSz, zxw:flags({base, 5})),
|
_ = wxStaticBoxSizer:add(SpecSz, ReturnSz, zxw:flags({base, 5})),
|
||||||
{SpecSz, CallControls, Dimensions}.
|
{SpecSz, CallControls, HasArgs}.
|
||||||
|
|
||||||
call_sizer(Frame, J, []) ->
|
call_sizer(Frame, J, []) ->
|
||||||
CallSz = wxStaticBoxSizer:new(?wxVERTICAL, Frame, [{label, J("Call Args")}]),
|
CallSz = wxStaticBoxSizer:new(?wxVERTICAL, Frame, [{label, J("Call Args")}]),
|
||||||
Args = wxStaticText:new(Frame, ?wxID_ANY, ["[", J("No Args"), "]"]),
|
Args = wxStaticText:new(Frame, ?wxID_ANY, ["[", J("No Args"), "]"]),
|
||||||
_ = wxStaticBoxSizer:add(CallSz, Args, zxw:flags({wide, 5})),
|
_ = wxStaticBoxSizer:add(CallSz, Args, zxw:flags({wide, 5})),
|
||||||
{CallSz, [], {500, 700}};
|
{CallSz, [], false};
|
||||||
call_sizer(Frame, J, CallArgs) ->
|
call_sizer(Frame, J, CallArgs) ->
|
||||||
ScrollWin = wxScrolledWindow:new(Frame),
|
ScrollWin = wxScrolledWindow:new(Frame),
|
||||||
ScrollSz = wxBoxSizer:new(?wxVERTICAL),
|
ScrollSz = wxBoxSizer:new(?wxVERTICAL),
|
||||||
@@ -172,7 +180,7 @@ call_sizer(Frame, J, CallArgs) ->
|
|||||||
#w{name = Name, id = wxTextCtrl:getId(C), wx = C}
|
#w{name = Name, id = wxTextCtrl:getId(C), wx = C}
|
||||||
end,
|
end,
|
||||||
Controls = lists:map(AddArg, CallArgs),
|
Controls = lists:map(AddArg, CallArgs),
|
||||||
{CallSz, Controls, {500, 900}}.
|
{CallSz, Controls, true}.
|
||||||
|
|
||||||
return_sizer(Frame, J, ReturnType) ->
|
return_sizer(Frame, J, ReturnType) ->
|
||||||
ReturnSz = wxStaticBoxSizer:new(?wxVERTICAL, Frame, [{label, J("Return Type")}]),
|
ReturnSz = wxStaticBoxSizer:new(?wxVERTICAL, Frame, [{label, J("Return Type")}]),
|
||||||
@@ -195,28 +203,28 @@ call_param_sizer(Frame, J) ->
|
|||||||
TTL_L = wxStaticText:new(Frame, ?wxID_ANY, "TTL"),
|
TTL_L = wxStaticText:new(Frame, ?wxID_ANY, "TTL"),
|
||||||
TTL_T = wxTextCtrl:new(Frame, ?wxID_ANY),
|
TTL_T = wxTextCtrl:new(Frame, ?wxID_ANY),
|
||||||
ok = wxTextCtrl:setValue(TTL_T, integer_to_list(DefTTL)),
|
ok = wxTextCtrl:setValue(TTL_T, integer_to_list(DefTTL)),
|
||||||
GasP_L = wxStaticText:new(Frame, ?wxID_ANY, J("Gas Price")),
|
|
||||||
GasP_T = wxTextCtrl:new(Frame, ?wxID_ANY),
|
|
||||||
ok = wxTextCtrl:setValue(GasP_T, integer_to_list(DefGasP)),
|
|
||||||
Gas_L = wxStaticText:new(Frame, ?wxID_ANY, J("Gas")),
|
Gas_L = wxStaticText:new(Frame, ?wxID_ANY, J("Gas")),
|
||||||
Gas_T = wxTextCtrl:new(Frame, ?wxID_ANY),
|
Gas_T = wxTextCtrl:new(Frame, ?wxID_ANY),
|
||||||
ok = wxTextCtrl:setValue(Gas_T, integer_to_list(DefGas)),
|
ok = wxTextCtrl:setValue(Gas_T, integer_to_list(DefGas)),
|
||||||
|
GasP_L = wxStaticText:new(Frame, ?wxID_ANY, J("Gas Price")),
|
||||||
|
GasP_T = wxTextCtrl:new(Frame, ?wxID_ANY),
|
||||||
|
ok = wxTextCtrl:setValue(GasP_T, integer_to_list(DefGasP)),
|
||||||
Amount_L = wxStaticText:new(Frame, ?wxID_ANY, J("TX Amount")),
|
Amount_L = wxStaticText:new(Frame, ?wxID_ANY, J("TX Amount")),
|
||||||
Amount_T = wxTextCtrl:new(Frame, ?wxID_ANY),
|
Amount_T = wxTextCtrl:new(Frame, ?wxID_ANY),
|
||||||
ok = wxTextCtrl:setValue(Amount_T, integer_to_list(DefAmount)),
|
ok = wxTextCtrl:setValue(Amount_T, integer_to_list(DefAmount)),
|
||||||
_ = wxFlexGridSizer:add(GridSz, TTL_L, zxw:flags({base, 5})),
|
_ = wxFlexGridSizer:add(GridSz, TTL_L, zxw:flags({base, 5})),
|
||||||
_ = wxFlexGridSizer:add(GridSz, TTL_T, zxw:flags({wide, 5})),
|
_ = wxFlexGridSizer:add(GridSz, TTL_T, zxw:flags({wide, 5})),
|
||||||
_ = wxFlexGridSizer:add(GridSz, GasP_L, zxw:flags({base, 5})),
|
|
||||||
_ = wxFlexGridSizer:add(GridSz, GasP_T, zxw:flags({wide, 5})),
|
|
||||||
_ = wxFlexGridSizer:add(GridSz, Gas_L, zxw:flags({base, 5})),
|
_ = wxFlexGridSizer:add(GridSz, Gas_L, zxw:flags({base, 5})),
|
||||||
_ = wxFlexGridSizer:add(GridSz, Gas_T, zxw:flags({wide, 5})),
|
_ = wxFlexGridSizer:add(GridSz, Gas_T, zxw:flags({wide, 5})),
|
||||||
|
_ = wxFlexGridSizer:add(GridSz, GasP_L, zxw:flags({base, 5})),
|
||||||
|
_ = wxFlexGridSizer:add(GridSz, GasP_T, zxw:flags({wide, 5})),
|
||||||
_ = wxFlexGridSizer:add(GridSz, Amount_L, zxw:flags({base, 5})),
|
_ = wxFlexGridSizer:add(GridSz, Amount_L, zxw:flags({base, 5})),
|
||||||
_ = wxFlexGridSizer:add(GridSz, Amount_T, zxw:flags({wide, 5})),
|
_ = wxFlexGridSizer:add(GridSz, Amount_T, zxw:flags({wide, 5})),
|
||||||
_ = wxSizer:add(ParamSz, GridSz, zxw:flags(wide)),
|
_ = wxSizer:add(ParamSz, GridSz, zxw:flags(wide)),
|
||||||
Params =
|
Params =
|
||||||
[{ "TTL", fun gte_0/1, TTL_T},
|
[{ "TTL", fun gte_0/1, TTL_T},
|
||||||
{J("Gas Price"), fun gt_0/1, GasP_T},
|
|
||||||
{J("Gas") , fun gt_0/1, Gas_T},
|
{J("Gas") , fun gt_0/1, Gas_T},
|
||||||
|
{J("Gas Price"), fun gt_0/1, GasP_T},
|
||||||
{J("TX Amount"), fun gte_0/1, Amount_T}],
|
{J("TX Amount"), fun gte_0/1, Amount_T}],
|
||||||
{ParamSz, Params}.
|
{ParamSz, Params}.
|
||||||
|
|
||||||
@@ -289,13 +297,13 @@ engage3(State, ChainID, Params) ->
|
|||||||
|
|
||||||
engage4(State = #s{fundef = {"init", init}, build = Build}, ChainID, Params, Args) ->
|
engage4(State = #s{fundef = {"init", init}, build = Build}, ChainID, Params, Args) ->
|
||||||
tell(info, "Args: ~p", [Args]),
|
tell(info, "Args: ~p", [Args]),
|
||||||
{CallerID, Nonce, TTL, GP, Gas, Amount} = Params,
|
{CallerID, Nonce, TTL, Gas, GP, Amount} = Params,
|
||||||
case hz:contract_create_built(CallerID, Nonce, Gas, GP, Amount, TTL, Build, Args) of
|
case hz:contract_create_built(CallerID, Nonce, Amount, TTL, Gas, GP, Build, Args) of
|
||||||
{ok, CreateTX} -> deploy(State, ChainID, CallerID, CreateTX);
|
{ok, CreateTX} -> deploy(State, ChainID, CallerID, CreateTX);
|
||||||
Error -> handle_troubling(State, Error)
|
Error -> handle_troubling(State, Error)
|
||||||
end;
|
end;
|
||||||
engage4(State = #s{fundef = {Name, Type}, con_id = ConID, build = Build}, ChainID, Params, Args) ->
|
engage4(State = #s{fundef = {Name, Type}, con_id = ConID, build = Build}, ChainID, Params, Args) ->
|
||||||
{CallerID, Nonce, TTL, GP, Gas, Amount} = Params,
|
{CallerID, Nonce, TTL, Gas, GP, Amount} = Params,
|
||||||
AACI = maps:get(aaci, Build),
|
AACI = maps:get(aaci, Build),
|
||||||
case hz:contract_call(CallerID, Nonce, Gas, GP, Amount, TTL, AACI, ConID, Name, Args) of
|
case hz:contract_call(CallerID, Nonce, Gas, GP, Amount, TTL, AACI, ConID, Name, Args) of
|
||||||
{ok, UnsignedTX} ->
|
{ok, UnsignedTX} ->
|
||||||
@@ -317,7 +325,7 @@ params(State = #s{kp = #w{wx = KeyPicker}}) ->
|
|||||||
|
|
||||||
params2(#s{params = Params}, PK, Nonce) ->
|
params2(#s{params = Params}, PK, Nonce) ->
|
||||||
case lists:foldl(fun extract/2, {ok, []}, Params) of
|
case lists:foldl(fun extract/2, {ok, []}, Params) of
|
||||||
{ok, [TTL, GP, Gas, Amount]} -> {ok, {PK, Nonce, TTL, GP, Gas, Amount}};
|
{ok, [Amount, GP, Gas, TTL]} -> {ok, {PK, Nonce, TTL, Gas, GP, Amount}};
|
||||||
Error -> Error
|
Error -> Error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@@ -344,9 +352,13 @@ deploy(State, ChainID, CallerID, CreateTX) ->
|
|||||||
|
|
||||||
deploy2(State, SignedTX) ->
|
deploy2(State, SignedTX) ->
|
||||||
case hz:post_tx(SignedTX) of
|
case hz:post_tx(SignedTX) of
|
||||||
{ok, Data} -> check_tx(State#s{tx_data = Data});
|
{ok, Data} ->
|
||||||
% {ok, WTF} -> handle_troubling(State, {error, WTF});
|
case maps:is_key("reason", Data) of
|
||||||
Error -> handle_troubling(State, Error)
|
false -> check_tx(State#s{tx_data = Data});
|
||||||
|
true -> handle_troubling(State, {error, Data})
|
||||||
|
end;
|
||||||
|
Error ->
|
||||||
|
handle_troubling(State, Error)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
@@ -358,7 +370,7 @@ do_call(State, ChainID, CallerID, UnsignedTX) ->
|
|||||||
|
|
||||||
do_call2(State, SignedTX) ->
|
do_call2(State, SignedTX) ->
|
||||||
case hz:post_tx(SignedTX) of
|
case hz:post_tx(SignedTX) of
|
||||||
{ok, Data} -> check_tx(State = #s{tx_data = Data});
|
{ok, Data} -> check_tx(State#s{tx_data = Data});
|
||||||
Error -> handle_troubling(State, Error)
|
Error -> handle_troubling(State, Error)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@@ -391,14 +403,14 @@ check_tx(State = #s{tx_data = TXData}) ->
|
|||||||
|
|
||||||
update_info(State = #s{tx_info = TXInfo, out = #w{wx = Out}}) ->
|
update_info(State = #s{tx_info = TXInfo, out = #w{wx = Out}}) ->
|
||||||
Formatted = io_lib:format("TXInfo: ~p~n", [TXInfo]),
|
Formatted = io_lib:format("TXInfo: ~p~n", [TXInfo]),
|
||||||
ok = wxStaticText:setLabel(Out, Formatted),
|
ok = wxTextCtrl:setValue(Out, Formatted),
|
||||||
State.
|
State.
|
||||||
|
|
||||||
|
|
||||||
copy(#s{tx_info = none}) ->
|
copy(#s{tx_info = none}) ->
|
||||||
ok;
|
ok;
|
||||||
copy(#s{out = #w{wx = Out}}) ->
|
copy(#s{out = #w{wx = Out}}) ->
|
||||||
Output = wxStaticText:getLabel(Out),
|
Output = wxTextCtrl:getValue(Out),
|
||||||
gd_lib:copy_to_clipboard(Output).
|
gd_lib:copy_to_clipboard(Output).
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+14
-25
@@ -233,8 +233,8 @@ handle_cast({dryrun_result, ConID, CallInfo}, State) ->
|
|||||||
ok = do_dryrun_result(State, ConID, CallInfo),
|
ok = do_dryrun_result(State, ConID, CallInfo),
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
handle_cast({trouble, Info}, State) ->
|
handle_cast({trouble, Info}, State) ->
|
||||||
ok = handle_troubling(State, Info),
|
NewState = handle_troubling(State, Info),
|
||||||
{noreply, State};
|
{noreply, NewState};
|
||||||
handle_cast(Unexpected, State) ->
|
handle_cast(Unexpected, State) ->
|
||||||
ok = log(warning, "Unexpected cast: ~tp~n", [Unexpected]),
|
ok = log(warning, "Unexpected cast: ~tp~n", [Unexpected]),
|
||||||
{noreply, State}.
|
{noreply, State}.
|
||||||
@@ -287,8 +287,9 @@ handle_event(Event, State) ->
|
|||||||
{noreply, State}.
|
{noreply, State}.
|
||||||
|
|
||||||
|
|
||||||
handle_troubling(#s{frame = Frame}, Info) ->
|
handle_troubling(State = #s{frame = Frame}, Info) ->
|
||||||
zxw:show_message(Frame, Info).
|
ok = zxw:show_message(Frame, Info),
|
||||||
|
State.
|
||||||
|
|
||||||
|
|
||||||
code_change(_, State, _) ->
|
code_change(_, State, _) ->
|
||||||
@@ -374,20 +375,16 @@ add_code_page2(State = #s{j = J}, {file, File}) ->
|
|||||||
add_code_page(State, {file, File}, Code);
|
add_code_page(State, {file, File}, Code);
|
||||||
Error ->
|
Error ->
|
||||||
Message = io_lib:format(J("Opening ~p failed with: ~p"), [File, Error]),
|
Message = io_lib:format(J("Opening ~p failed with: ~p"), [File, Error]),
|
||||||
ok = handle_troubling(State, Message),
|
handle_troubling(State, Message)
|
||||||
State
|
|
||||||
end;
|
end;
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
Message = io_lib:format(J("Opening ~p failed with: ~p"), [File, Reason]),
|
Message = io_lib:format(J("Opening ~p failed with: ~p"), [File, Reason]),
|
||||||
ok = handle_troubling(State, Message),
|
handle_troubling(State, Message)
|
||||||
State
|
|
||||||
end;
|
end;
|
||||||
add_code_page2(State, {hash, Address}) ->
|
add_code_page2(State, {hash, Address}) ->
|
||||||
open_hash2(State, Address).
|
open_hash2(State, Address).
|
||||||
|
|
||||||
add_code_page(State = #s{tabs = TopBook, code = {Codebook, Pages}}, Location, Code) ->
|
add_code_page(State = #s{tabs = TopBook, code = {Codebook, Pages}}, Location, Code) ->
|
||||||
Color = wxSystemSettings:getColour(?wxSYS_COLOUR_WINDOW),
|
|
||||||
tell("Color: ~p", [Color]),
|
|
||||||
Window = wxWindow:new(Codebook, ?wxID_ANY),
|
Window = wxWindow:new(Codebook, ?wxID_ANY),
|
||||||
PageSz = wxBoxSizer:new(?wxHORIZONTAL),
|
PageSz = wxBoxSizer:new(?wxHORIZONTAL),
|
||||||
|
|
||||||
@@ -612,8 +609,7 @@ open_hash2(State, Address) ->
|
|||||||
{ok, Source} ->
|
{ok, Source} ->
|
||||||
open_hash3(State, Address, Source);
|
open_hash3(State, Address, Source);
|
||||||
Error ->
|
Error ->
|
||||||
ok = handle_troubling(State, Error),
|
handle_troubling(State, Error)
|
||||||
State
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
open_hash3(State, Address, Source) ->
|
open_hash3(State, Address, Source) ->
|
||||||
@@ -640,15 +636,11 @@ save(State = #s{prefs = Prefs, code = {Codebook, Pages}}) ->
|
|||||||
case filelib:ensure_dir(Path) of
|
case filelib:ensure_dir(Path) of
|
||||||
ok ->
|
ok ->
|
||||||
case file:write_file(Path, Source) of
|
case file:write_file(Path, Source) of
|
||||||
ok ->
|
ok -> State;
|
||||||
State;
|
Error -> handle_troubling(State, Error)
|
||||||
Error ->
|
|
||||||
ok = handle_troubling(State, Error),
|
|
||||||
State
|
|
||||||
end;
|
end;
|
||||||
Error ->
|
Error ->
|
||||||
ok = handle_troubling(State, Error),
|
handle_troubling(State, Error)
|
||||||
State
|
|
||||||
end;
|
end;
|
||||||
Page = #p{path = {hash, Hash}, code = Widget} ->
|
Page = #p{path = {hash, Hash}, code = Widget} ->
|
||||||
DefDir =
|
DefDir =
|
||||||
@@ -718,12 +710,10 @@ save_dialog(State = #s{frame = Frame, j = J, prefs = Prefs, code = {Codebook, Pa
|
|||||||
NewCode = {Codebook, NewPages},
|
NewCode = {Codebook, NewPages},
|
||||||
State#s{prefs = NewPrefs, code = NewCode};
|
State#s{prefs = NewPrefs, code = NewCode};
|
||||||
Error ->
|
Error ->
|
||||||
ok = handle_troubling(State, Error),
|
handle_troubling(State, Error)
|
||||||
State
|
|
||||||
end;
|
end;
|
||||||
Error ->
|
Error ->
|
||||||
ok = handle_troubling(State, Error),
|
handle_troubling(State, Error)
|
||||||
State
|
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
?wxID_CANCEL ->
|
?wxID_CANCEL ->
|
||||||
@@ -773,8 +763,7 @@ load2(State, Address) ->
|
|||||||
{ok, Source} ->
|
{ok, Source} ->
|
||||||
load3(State, Address, Source);
|
load3(State, Address, Source);
|
||||||
Error ->
|
Error ->
|
||||||
ok = handle_troubling(State, Error),
|
handle_troubling(State, Error)
|
||||||
State
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
load3(State = #s{tabs = TopBook, cons = {Consbook, Pages}, buttons = Buttons, j = J},
|
load3(State = #s{tabs = TopBook, cons = {Consbook, Pages}, buttons = Buttons, j = J},
|
||||||
|
|||||||
Reference in New Issue
Block a user