anchor.diff:  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)}),
  +handle_info(#wx{event = #wxKey{type = char, keyCode = ?WXK_RETURN}}, #state{buffer = Buffer, caret = #caret{line = Line} = Caret} = State) ->
  +	gen_server:cast(data_buffer, {eol, caret_to_buffer_coords(Caret, Buffer)}),
   	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, {delete_left, caret_to_buffer_coords(Caret, Buffer)}),
   	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)}),
  +handle_info(#wx{event = #wxKey{type = char, keyCode = ?WXK_DELETE}}, #state{buffer = Buffer, caret = Caret} = State) ->
  +	gen_server:cast(data_buffer, {delete_right, caret_to_buffer_coords(Caret, Buffer)}),
   	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) ->
  +handle_info(#wx{event = #wxKey{type = char, uniChar = Char}}, #state{buffer = Buffer, 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, {char, [Char], caret_to_buffer_coords(Caret, Buffer)}),
   	gen_server:cast(data_buffer, {get_buffer, self()}),
   	%% Don't change caret directly.
   	{noreply, State#state{caret = Caret#caret{column = Column + 1}}};
  
positive.code: 	NumLines = ee_buffer:get_num_lines(Buffer),
  	case LineNo + NumLinesToMove > NumLines of
  		true ->
  			Caret#caret{line = NumLines, column = ee_buffer:get_line_length(Buffer, NumLines) + 1};
  		_ ->
  			move_caret_down_and_truncate(Caret, NumLinesToMove, ee_buffer:get_line_length(Buffer, LineNo + NumLinesToMove))
  	end.
  
  move_caret_down_and_truncate(#caret{line = LineNo, column = Column} = Caret, NumLinesToMove, NextLineLength) when Column > NextLineLength + 1 ->
  	Caret#caret{line = LineNo + NumLinesToMove, column = NextLineLength + 1};
  move_caret_down_and_truncate(#caret{line = LineNo} = Caret, NumLinesToMove, _NextLineLength) ->
  	Caret#caret{line = LineNo + NumLinesToMove}.
  
  move_caret_to_beginning_of_line(#caret{} = Caret, _) ->
  	Caret#caret{column = 1}.
  
  move_caret_to_end_of_line(#caret{line = LineNo} = Caret, Buffer) ->
  	Caret#caret{column = ee_buffer:get_line_length(Buffer, LineNo) + 1}.
  
  move_caret_up_one_page(Caret, Buffer) ->
  	%% Let's pretend one page is 10 lines for now.
  
negative.code: 
  move_caret_left(#caret{line = 1, column = 1} = Caret, _Buffer) ->
  	Caret;
  move_caret_left(#caret{line = LineNo, column = 1}, Buffer) ->
  	Coords = ee_buffer:new_buffer_coords(LineNo - 1, ee_buffer:get_line_length(Buffer, LineNo - 1) + 1),
  	buffer_coords_to_caret(Coords, Buffer);
  move_caret_left(#caret{} = Caret, Buffer) ->
  	#ee_buffer_coords{line_no = LineNo, line_offset = LineOffset} = caret_to_buffer_coords(Caret, Buffer),
  	buffer_coords_to_caret(ee_buffer:new_buffer_coords(LineNo, LineOffset - 1), Buffer).
  
  move_caret_right(#caret{} = Caret, Buffer) ->
  	#ee_buffer_coords{line_no = LineNo, line_offset = LineOffset} = caret_to_buffer_coords(Caret, Buffer),
  	case LineOffset =< ee_buffer:get_line_length(Buffer, LineNo) of
  		true ->
  			buffer_coords_to_caret(ee_buffer:new_buffer_coords(LineNo, LineOffset + 1), Buffer);
  		_ ->
  			move_caret_right_to_next_line(Caret, ee_buffer:get_num_lines(Buffer))
  	end.
  