anchor.diff:  	%% Close document.
   	ee_document:close(FocusDocPid),
   	{ok, State};
  -handle_key(#wxKey{type = char, keyCode = ?WXK_LEFT}, #state{win = #main_window{window = Window}, doc_set = DocSet0} = 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(Window),
  -	{ok, State#state{doc_set = DocSet1}};
  -handle_key(#wxKey{type = char, keyCode = ?WXK_RIGHT}, #state{win = #main_window{window = Window}, doc_set = DocSet0} = State) ->
  +	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(Window),
  -	{ok, State#state{doc_set = DocSet1}};
  -handle_key(#wxKey{type = char, keyCode = ?WXK_UP}, #state{win = #main_window{window = Window}, doc_set = DocSet0} = State) ->
  +	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(Window),
  -	{ok, State#state{doc_set = DocSet1}};
  -handle_key(#wxKey{type = char, keyCode = ?WXK_DOWN}, #state{win = #main_window{window = Window}, doc_set = DocSet0} = State) ->
  +	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(Window),
  -	{ok, State#state{doc_set = DocSet1}};
  -handle_key(#wxKey{type = char, keyCode = ?WXK_HOME}, #state{win = #main_window{window = Window}, doc_set = DocSet0} = State) ->
  +	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(Window),
  -	{ok, State#state{doc_set = DocSet1}};
  -handle_key(#wxKey{type = char, keyCode = ?WXK_END}, #state{win = #main_window{window = Window}, doc_set = DocSet0} = State) ->
  +	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(Window),
  -	{ok, State#state{doc_set = DocSet1}};
  -handle_key(#wxKey{type = char, keyCode = ?WXK_PAGEUP}, #state{win = #main_window{window = Window}, doc_set = DocSet0} = State) ->
  +	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(Window),
  -	{ok, State#state{doc_set = DocSet1}};
  -handle_key(#wxKey{type = char, keyCode = ?WXK_PAGEDOWN}, #state{win = #main_window{window = Window}, doc_set = DocSet0} = State) ->
  +	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(Window),
  +	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.
  
positive.code: handle_cast(Msg, _State) ->
  	erlang:error({bad_cast, Msg}).
  
  handle_info(#ee_pubsub_message{message = {document_inserted, DocPid}}, #state{win = #main_window{window = Window}, doc_set = DocSet0} = State) ->
  	{ok, DocSet1} = ee_doc_set:add_focus_document_view(DocSet0, DocPid),
  	ee_document:add_subscriber(DocPid, self()),
  	{ok, Buffer} = ee_document:get_buffer(DocPid),
  	%% TODO: Look intoif this is efficient (looking up the doc view by pid again)
  	{ok, DocSet2} = ee_doc_set:update_document_view_buffer(DocSet1, DocPid, Buffer),
  	wxFrame:refresh(Window),
  	{noreply, State#state{doc_set = DocSet2}};
  handle_info(#ee_pubsub_message{message = {document_deleted, DocPid}}, #state{doc_set = DocSet0} = State) ->
  	{ok, DocSet1} = ee_doc_set:remove_document_view(DocSet0, DocPid),
  	{noreply, State#state{doc_set = DocSet1}};
  handle_info(#ee_pubsub_message{message = {buffer_update, Buffer}, publisher = DocPid}, #state{win = #main_window{window = Window}, doc_set = DocSet0} = State) ->
  	{ok, DocSet1} = ee_doc_set:update_document_view_buffer(DocSet0, DocPid, Buffer),
  	wxFrame:refresh(Window),
  	{noreply, State#state{doc_set = DocSet1}};
  handle_info(blink_caret, #state{win = #main_window{window = Window}, blink_caret = BlinkCaret0} = State) ->
  	BlinkCaret1 = blink_caret(BlinkCaret0),
  	wxFrame:refresh(Window),
  	{noreply, State#state{blink_caret = BlinkCaret1}};
  handle_info(timeout, State) ->
  	wx:new(),
  
negative.code: -include("ee_doc_set.hrl").
  -include("ee_pubsub.hrl").
  
  -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{}}).
  
  