anchor.diff:  -include("ee_caret.hrl").
   
   -record(main_window, {window, status_bar}).
  --record(state, {win = #main_window{}, buffer, caret = #ee_caret{}, documents = []}).
  +-record(doc_view, {pid, buffer, caret = #ee_caret{}}).
  +-record(doc_set, {focus_doc, background_docs = []}).
  +-record(state, {win = #main_window{}, doc_set = #doc_set{}}).
   
   %% ===================================================================
   %% API
  
positive.code: 	wx:destroy(),
  	ok.
  
  handle_call({get_buffer}, _From, #state{buffer = Buffer, caret = Caret} = State) ->
  	{reply, {Buffer, Caret}, State};
  handle_call(Msg, _From, _State) ->
  	erlang:error({bad_call, Msg}).
  
negative.code: handle_info(#wx{event = #wxKey{} = KeyEvent}, State) ->
  	{noreply, handle_key(KeyEvent, State)};
  %% TODO: replace raw ee_pubsub message with a record.
  handle_info({ee_pubsub, {document_inserted, DocPid}, _From}, #state{win = #main_window{window = Window}, doc_set = DocSet0} = State) ->
  	{ok, DocSet1} = add_focus_document_view(DocPid, DocSet0),
  	ee_buffer_server:add_subscriber(DocPid, self()),
  	{ok, Buffer} = ee_buffer_server:get_buffer(DocPid),
  	%% TODO: Look intoif this is efficient (looking up the doc view by pid again)
  	{ok, DocSet2} = update_document_view_buffer(DocPid, DocSet1, Buffer),
  	wxFrame:refresh(Window),
  	{noreply, State#state{doc_set = DocSet2}};
  handle_info({ee_pubsub, {document_deleted, DocPid}, _From}, #state{doc_set = DocSet0} = State) ->
  	{ok, DocSet1} = remove_document_view(DocPid, DocSet0),
  	{noreply, State#state{doc_set = DocSet1}};
  handle_info({ee_pubsub, {buffer_update, Buffer}, DocPid}, #state{win = #main_window{window = Window}, doc_set = DocSet0} = State) ->
  	{ok, DocSet1} = update_document_view_buffer(DocPid, DocSet0, Buffer),
  	wxFrame:refresh(Window),
  	{noreply, State#state{doc_set = DocSet1}};
  handle_info(timeout, State) ->
  	wx:new(),
  	{noreply, State#state{win = create_window()}};
  