anchor.diff:  draw_buffer_line(DC, [Char|T], LiteralCharsRev, XStart, Y, SpaceWidth) ->
   	draw_buffer_line(DC, T, [Char|LiteralCharsRev], XStart, Y, SpaceWidth).
   
  -draw_caret(DC, Buffer, #caret{line = LineNo, column = Column}, LineHeight, SpaceWidth) ->
  +draw_caret(DC, Buffer, Caret, LineHeight, SpaceWidth) ->
  +	#ee_buffer_coords{line_no = LineNo, line_offset = LineOffset} = caret_to_buffer_coords(Caret, Buffer),
   	Line = ee_buffer:get_line(Buffer, LineNo),
  -	draw_caret_on_line(DC, lists:sublist(ee_buffer:get_line_contents(Line), Column - 1), [], 0, (LineNo - 1) * LineHeight, LineHeight, SpaceWidth).
  +	draw_caret_on_line(DC, lists:sublist(ee_buffer:get_line_contents(Line), LineOffset - 1), [], 0, (LineNo - 1) * LineHeight, LineHeight, SpaceWidth).
   
   draw_caret_on_line(DC, [], LiteralCharsRev, XStart, Y, H, _) ->
   	LiteralChars = lists:reverse(LiteralCharsRev),
  -	{W, _} = ?dbg_print(wxDC:getTextExtent(DC, LiteralChars)),
  +	{W, _} = wxDC:getTextExtent(DC, LiteralChars),
   	ok = wxDC:drawLine(DC, {XStart + W, Y}, {XStart + W, Y + H});
   draw_caret_on_line(DC, [?ASCII_TAB|T], LiteralCharsRev, XStart, Y, H, SpaceWidth) ->
   	LiteralChars = lists:reverse(LiteralCharsRev),
  
positive.code: handle_info(#wx{event = #wxKey{type = char, keyCode = ?WXK_PAGEDOWN}}, #state{win = #main_window{window = Window}, buffer = Buffer, caret = Caret} = State) ->
  	wxFrame:refresh(Window),
  	{noreply, State#state{caret = move_caret_down_one_page(Caret, Buffer)}};
  handle_info(#wx{event = #wxKey{type = char, keyCode = ?WXK_RETURN}}, #state{caret = #caret{line = Line} = Caret} = State) ->
  	gen_server:cast(data_buffer, {eol, caret_to_buffer_coords(Caret)}),
  	gen_server:cast(data_buffer, {get_buffer, self()}),
  	%% Don't change caret directly.
  	{noreply, State#state{caret = Caret#caret{line = Line + 1, column = 1}}};
  handle_info(#wx{event = #wxKey{type = char, keyCode = ?WXK_BACK}}, #state{buffer = Buffer, caret = Caret} = State) ->
  	gen_server:cast(data_buffer, {delete_left, caret_to_buffer_coords(Caret)}),
  	gen_server:cast(data_buffer, {get_buffer, self()}),
  	{noreply, State#state{caret = move_caret_left(Caret, Buffer)}};	
  handle_info(#wx{event = #wxKey{type = char, keyCode = ?WXK_DELETE}}, #state{caret = Caret} = State) ->
  	gen_server:cast(data_buffer, {delete_right, caret_to_buffer_coords(Caret)}),
  	gen_server:cast(data_buffer, {get_buffer, self()}),
  	{noreply, State};	
  handle_info(#wx{event = #wxKey{type = char, uniChar = Char}}, #state{caret = #caret{column = Column} = Caret} = State) ->
  	%% Send message to data buffer to update.
  	gen_server:cast(data_buffer, {char, [Char], caret_to_buffer_coords(Caret)}),
  	gen_server:cast(data_buffer, {get_buffer, self()}),
  	%% Don't change caret directly.
  	{noreply, State#state{caret = Caret#caret{column = Column + 1}}};
  
negative.code: 	%% Let's pretend one page is 10 lines for now.
  	move_caret_down(Caret, 10, Buffer).
  
  caret_to_buffer_coords(#caret{line = LineNo, column = ColNo}, Buffer) ->
  	LineContents = ee_buffer:get_line_contents(ee_buffer:get_line(Buffer, LineNo)),
  	%% Get each char on line until colno has been reached.
  	Offset = caret_to_buffer_coords_loop(LineContents, 1, ColNo),
  	ee_buffer:new_buffer_coords(LineNo, Offset).
  
  caret_to_buffer_coords_loop([], Offset, _RemainCols) ->
  	Offset;
  caret_to_buffer_coords_loop(_Chars, Offset, RemainCols) when RemainCols =< 1 ->
  	Offset;
  caret_to_buffer_coords_loop([$\t|T], Offset, RemainCols) ->
  	caret_to_buffer_coords_loop(T, Offset + 1, RemainCols - 4);
  caret_to_buffer_coords_loop([_Char|T], Offset, RemainCols) ->
  	caret_to_buffer_coords_loop(T, Offset + 1, RemainCols - 1).
  	
  buffer_coords_to_caret(#ee_buffer_coords{line_no = LineNo, line_offset = LineOffset}, Buffer) ->
  	LineContents = ee_buffer:get_line_contents(ee_buffer:get_line(Buffer, LineNo)),
  	%% Get each char on line until colno has been reached.
  	ColNo = buffer_coords_to_caret_loop(LineContents, 1, LineOffset),
  	#caret{line = LineNo, column = ColNo}.
  
  buffer_coords_to_caret_loop([], Cols, _RemainOffset) ->
  	Cols;
  buffer_coords_to_caret_loop(_Chars, Cols, RemainOffset) when RemainOffset =< 1 ->
  	Cols;
  buffer_coords_to_caret_loop([$\t|T], Cols, RemainOffset) ->
  	buffer_coords_to_caret_loop(T, Cols + 4, RemainOffset - 1);
  buffer_coords_to_caret_loop([_Char|T], Cols, RemainOffset) ->
  	buffer_coords_to_caret_loop(T, Cols + 1, RemainOffset - 1).
  