简单的语法高亮 Erlang 编辑器

-module(erledit).
-export([start/0]).
-include("D:/Program Files/erl5.6.3/lib/wx-0.97.0623/include/wx.hrl").

start() ->
Wx = wx:new(),
Frame = wxFrame:new(Wx, 1, "erl edit", []),
Text = wxStyledTextCtrl:new(Frame),
wxStyledTextCtrl:setLexerLanguage(Text, "erlang"),
io:format("Current Lexer is ~w~n", [wxStyledTextCtrl:getLexer(Text)]),
wxStyledTextCtrl:styleSetForeground(Text, 0, {255, 0, 0}),
wxStyledTextCtrl:styleSetForeground(Text, 1, {0, 255, 0}),
wxStyledTextCtrl:styleSetForeground(Text, 2, {0, 0, 255}),
wxStyledTextCtrl:styleSetForeground(Text, 3, {128, 100, 0}),
wxStyledTextCtrl:styleSetForeground(Text, 4, {30, 200, 90}),
wxStyledTextCtrl:styleSetForeground(Text, 5, {0, 255, 100}),
wxStyledTextCtrl:styleSetForeground(Text, 6, {0, 255, 190}),
wxStyledTextCtrl:styleSetForeground(Text, 7, {50, 100, 0}),
wxFrame:show(Frame),
wxFrame:connect(Frame, close_window, [{skip, true}]),
loop().

loop() ->
receive
#wx{event=#wxClose{}} ->
io:format("closed~n");
_Event ->
loop()
end. 用到 Erlang 最新 Release Erlang R12B-3wxErlang(wxWidgets 的 Erlang wrapper)。配色是我随意写的,只做演示之用,不要在意:)

你可能感兴趣的:(erlang)