Index: src/orca/braille.py
===================================================================
--- src/orca/braille.py	(revision 4023)
+++ src/orca/braille.py	(working copy)
@@ -252,6 +252,28 @@
 #
 cursorCell = 0
 
+
+# Wether or not to preserve cursorCell when setFocus is called.
+# If true, braille display does not jump when inserting/editing text after
+# a routing key is pressed.
+preserveCursorCell = True
+
+# Override the preservation rule, if cusror is too close to left/right boundary
+# of the braille display. In this case reposition the cursor to the cell
+# specified below.
+# This is helpful, because it ensures that the surrounding of the cursor 
+# position is visible when editing at the beginning or end of the braille
+# display.
+# Set to something <=0 to disable
+
+stayAwayFromLeftMargin = 3
+
+stayAwayFromRightMargin = 3
+
+
+
+
+
 def _printBrailleEvent(level, command):
     """Prints out a Braille event.  The given level may be overridden
     if the eventDebugLevel (see debug.setEventDebugLevel) is greater in
@@ -850,6 +872,10 @@
     """
 
     global _regionWithFocus
+    global cursorCell
+    global preserveCursorCell 
+    global stayAwayFromLeftMargin
+    global stayAwayFromRightMargin
 
     _regionWithFocus = region
 
@@ -883,7 +909,19 @@
     # so the cursor will be on the last cell of the display.
     #
     if _regionWithFocus.cursorOffset >= _displaySize[0]:
-        offset += _regionWithFocus.cursorOffset - _displaySize[0] + 1
+        if preserveCursorCell:
+          print "Preserving cursor position\n"
+          if cursorCell < stayAwayFromLeftMargin:
+            cursorCell = stayAwayFromLeftMargin
+            print "Adjusted left margin\n"
+          if cursorCell > _displaySize[0] - stayAwayFromRightMargin:
+            cursorCell= _displaySize[0] - stayAwayFromRightMargin
+            print "Adjusted right margin\n"
+          offset += _regionWithFocus.cursorOffset + 1 - cursorCell
+          print "CursorCell=", cursorCell, "\n"
+        else:
+          print "Not preserving cursor position\n"
+          offset += _regionWithFocus.cursorOffset + 1 - _displaySize[0]
 
     viewport[0] = max(0, offset)
 
