anchor.diff:  -include("ee_doc_set.hrl").
   -include("ee_pubsub.hrl").
   
  --record(main_window, {window, status_bar}).
  +-record(main_window, {window, text_panel, text_cursor, status_bar}).
   -record(blink_caret, {state = on, timer}).
   -record(state, {win = #main_window{}, doc_set = #ee_doc_set{}, blink_caret = #blink_caret{}}).
   
  
positive.code: 
  create_window() ->
  	%% Create the window.
  	Window = wxFrame:new(wx:null(), -1, "erledit", [{size, {800, 600}}]),
  	StatusBar = wxFrame:createStatusBar(Window),
  	ok = wxStatusBar:setStatusText(StatusBar, ""),
  
  	%% Subscribe to events.
  	wxFrame:connect(Window, close_window, [{callback, fun handle_wx_event/2}]),
  	wxFrame:connect(Window, char, [{callback, fun handle_wx_event/2}]),
  	wxFrame:connect(Window, key_down, [{callback, fun handle_wx_event/2}]),
  	wxFrame:connect(Window, key_up, [{callback, fun handle_wx_event/2}]),
  	wxFrame:connect(Window, paint
  		, [{callback, fun handle_paint/2}]
  		),
  
  	%% Show window.
  	wxFrame:show(Window),
  	wxFrame:maximize(Window),
  	#main_window{window = Window, status_bar = StatusBar}.
  
  handle_wx_event(WxMessage, WxEvent) ->
  	case gen_server:call(?MODULE, WxMessage) of
  
negative.code: 	%% Close document.
  	ee_document:close(FocusDocPid),
  	{ok, State};
  handle_key(#wxKey{type = char, keyCode = ?WXK_LEFT}, #state{win = #main_window{text_panel = TextPanel}, doc_set = DocSet0} = State) ->
  	{ok, DocSet1} = ee_doc_set:move_caret_left_in_focus_doc(DocSet0),
  	wxFrame:refresh(TextPanel),
  	{ok, State#state{doc_set = DocSet1}};
  handle_key(#wxKey{type = char, keyCode = ?WXK_RIGHT}, #state{win = #main_window{text_panel = TextPanel}, doc_set = DocSet0} = State) ->
  	{ok, DocSet1} = ee_doc_set:move_caret_right_in_focus_doc(DocSet0),
  	wxFrame:refresh(TextPanel),
  	{ok, State#state{doc_set = DocSet1}};
  handle_key(#wxKey{type = char, keyCode = ?WXK_UP}, #state{win = #main_window{text_panel = TextPanel}, doc_set = DocSet0} = State) ->
  	{ok, DocSet1} = ee_doc_set:move_caret_up_in_focus_doc(DocSet0),
  	wxFrame:refresh(TextPanel),
  	{ok, State#state{doc_set = DocSet1}};
  handle_key(#wxKey{type = char, keyCode = ?WXK_DOWN}, #state{win = #main_window{text_panel = TextPanel}, doc_set = DocSet0} = State) ->
  	{ok, DocSet1} = ee_doc_set:move_caret_down_in_focus_doc(DocSet0),
  	wxFrame:refresh(TextPanel),
  	{ok, State#state{doc_set = DocSet1}};
  handle_key(#wxKey{type = char, keyCode = ?WXK_HOME}, #state{win = #main_window{text_panel = TextPanel}, doc_set = DocSet0} = State) ->
  	{ok, DocSet1} = ee_doc_set:move_caret_to_line_start_in_focus_doc(DocSet0),
  	wxFrame:refresh(TextPanel),
  	{ok, State#state{doc_set = DocSet1}};
  handle_key(#wxKey{type = char, keyCode = ?WXK_END}, #state{win = #main_window{text_panel = TextPanel}, doc_set = DocSet0} = State) ->
  	{ok, DocSet1} = ee_doc_set:move_caret_to_line_end_in_focus_doc(DocSet0),
  	wxFrame:refresh(TextPanel),
  	{ok, State#state{doc_set = DocSet1}};
  handle_key(#wxKey{type = char, keyCode = ?WXK_PAGEUP}, #state{win = #main_window{text_panel = TextPanel}, doc_set = DocSet0} = State) ->
  	{ok, DocSet1} = ee_doc_set:move_caret_up_one_page_in_focus_doc(DocSet0),
  	wxFrame:refresh(TextPanel),
  	{ok, State#state{doc_set = DocSet1}};
  handle_key(#wxKey{type = char, keyCode = ?WXK_PAGEDOWN}, #state{win = #main_window{text_panel = TextPanel}, doc_set = DocSet0} = State) ->
  	{ok, DocSet1} = ee_doc_set:move_caret_down_one_page_in_focus_doc(DocSet0),
  	wxFrame:refresh(TextPanel),
  	{ok, State#state{doc_set = DocSet1}};
  handle_key(#wxKey{type = char, keyCode = ?WXK_RETURN}, #state{doc_set = DocSet0} = State) ->
  	%% TODO: Refactor so that doc_set internals are hidden.
  