Make styled text control when loading
This commit is contained in:
parent
2952822a8f
commit
dc0b620a4c
@ -929,6 +929,24 @@ save(State = #s{frame = Frame, j = J, prefs = Prefs, code = {Codebook, Pages}})
|
|||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
make_plain_text_control(Parent) ->
|
||||||
|
CodeTxStyle = {style, ?wxTE_MULTILINE
|
||||||
|
bor ?wxTE_PROCESS_TAB
|
||||||
|
bor ?wxTE_DONTWRAP
|
||||||
|
bor ?wxTE_READONLY},
|
||||||
|
CodeTx = wxTextCtrl:new(Parent, ?wxID_ANY, [CodeTxStyle]),
|
||||||
|
Mono = wxFont:new(10, ?wxMODERN, ?wxNORMAL, ?wxNORMAL, [{face, "Monospace"}]),
|
||||||
|
TextAt = wxTextAttr:new(),
|
||||||
|
ok = wxTextAttr:setFont(TextAt, Mono),
|
||||||
|
true = wxTextCtrl:setDefaultStyle(CodeTx, TextAt),
|
||||||
|
CodeTx.
|
||||||
|
|
||||||
|
make_source_text_control(Parent) ->
|
||||||
|
case ?editorMode of
|
||||||
|
plain -> make_plain_text_control(Parent);
|
||||||
|
sophia -> gd_sophia_editor:new(Parent)
|
||||||
|
end.
|
||||||
|
|
||||||
get_source(Widget) ->
|
get_source(Widget) ->
|
||||||
case ?editorMode of
|
case ?editorMode of
|
||||||
plain -> wxTextCtrl:getValue(Widget);
|
plain -> wxTextCtrl:getValue(Widget);
|
||||||
@ -940,7 +958,6 @@ set_source(Widget, Src) ->
|
|||||||
plain -> wxTextCtrl:setValue(Widget, Src);
|
plain -> wxTextCtrl:setValue(Widget, Src);
|
||||||
sophia -> gd_sophia_editor:set_text(Widget, Src)
|
sophia -> gd_sophia_editor:set_text(Widget, Src)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
% TODO: Break this down -- tons of things in here recur.
|
% TODO: Break this down -- tons of things in here recur.
|
||||||
rename(State = #s{frame = Frame, j = J, prefs = Prefs, code = {Codebook, Pages}}) ->
|
rename(State = #s{frame = Frame, j = J, prefs = Prefs, code = {Codebook, Pages}}) ->
|
||||||
@ -1079,15 +1096,7 @@ load3(State = #s{tabs = TopBook, cons = {Consbook, Pages}, buttons = Buttons, j
|
|||||||
PageSz = wxBoxSizer:new(?wxVERTICAL),
|
PageSz = wxBoxSizer:new(?wxVERTICAL),
|
||||||
ProgSz = wxBoxSizer:new(?wxHORIZONTAL),
|
ProgSz = wxBoxSizer:new(?wxHORIZONTAL),
|
||||||
CodeSz = wxStaticBoxSizer:new(?wxVERTICAL, Window, [{label, J("Contract Source")}]),
|
CodeSz = wxStaticBoxSizer:new(?wxVERTICAL, Window, [{label, J("Contract Source")}]),
|
||||||
CodeTxStyle = {style, ?wxTE_MULTILINE
|
CodeTx = make_source_text_control(Window),
|
||||||
bor ?wxTE_PROCESS_TAB
|
|
||||||
bor ?wxTE_DONTWRAP
|
|
||||||
bor ?wxTE_READONLY},
|
|
||||||
CodeTx = wxTextCtrl:new(Window, ?wxID_ANY, [CodeTxStyle]),
|
|
||||||
Mono = wxFont:new(10, ?wxMODERN, ?wxNORMAL, ?wxNORMAL, [{face, "Monospace"}]),
|
|
||||||
TextAt = wxTextAttr:new(),
|
|
||||||
ok = wxTextAttr:setFont(TextAt, Mono),
|
|
||||||
true = wxTextCtrl:setDefaultStyle(CodeTx, TextAt),
|
|
||||||
ok = set_source(CodeTx, Source),
|
ok = set_source(CodeTx, Source),
|
||||||
_ = wxSizer:add(CodeSz, CodeTx, zxw:flags(wide)),
|
_ = wxSizer:add(CodeSz, CodeTx, zxw:flags(wide)),
|
||||||
ScrollWin = wxScrolledWindow:new(Window),
|
ScrollWin = wxScrolledWindow:new(Window),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user