Pan the document when the mosue cursor approaches the edges
of the window.
966719
function pan() {
		var range = 0.12,
			rangeX = window.innerWidth * range,
			rangeY = window.innerHeight * range,
			scrollOffset = getScrollOffset();

		// Up
		if( mouseY < rangeY ) {
			window.scroll( scrollOffset.x, scrollOffset.y - ( 1 - ( mouseY / rangeY ) ) * ( 14 / level ) );
		}
		// Down
		else if( mouseY > window.innerHeight - rangeY ) {
			window.scroll( scrollOffset.x, scrollOffset.y + ( 1 - ( window.innerHeight - mouseY ) / rangeY ) * ( 14 / level ) );
		}

		// Left
		if( mouseX < rangeX ) {
			window.scroll( scrollOffset.x - ( 1 - ( mouseX / rangeX ) ) * ( 14 / level ), scrollOffset.y );
		}
		// Right
		else if( mouseX > window.innerWidth - rangeX ) {
			window.scroll( scrollOffset.x + ( 1 - ( window.innerWidth - mouseX ) / rangeX ) * ( 14 / level ), scrollOffset.y );
		}
	}
1083735
def ms_pan(self, viewer, event, data_x, data_y):
        
        if not self.canpan:
            return True

        x, y = viewer.get_last_win_xy()
        if event.state == 'move':
            data_x, data_y = self.get_new_pan(viewer, x, y,
                                              ptype=self._pantype)
            viewer.panset_xy(data_x, data_y)

        elif event.state == 'down':
            self.pan_set_origin(viewer, x, y, data_x, data_y)
            self.pan_start(viewer, ptype=2)

        else:
            self.pan_stop(viewer)
        return True
32315
def cursor_end
    blen = @buffer.rstrip.length
    if blen < @width
      set_form_col blen
    else
      # there is a problem here FIXME. 
      @pcol = blen-@width
      #set_form_col @width-1
      set_form_col blen
    end
    @curpos = blen # this is position in array where editing or motion is to happen regardless of what you see
                   # regardless of pcol (panning)
    #  $log.debug " crusor END cp:#{@curpos} pcol:#{@pcol} b.l:#{@buffer.length} d_l:#{@width} fc:#{@form.col}"
    #set_form_col @buffer.length
  end
796971
def _cursorUp(self):
        
        if self.historyPos > 0:
            self.historyPos -= 1
            clearLen = len(self.inputBuffer)
            self.inputBuffer = list(self.history[self.historyPos])
            self.cursorPos = len(self.inputBuffer)
            self._refreshInputPrompt(clearLen)
505102
def snap_left(window, width=None):
    
    if not width:
        width = window.width()
    rect = QApplication.desktop().screenGeometry()
    window.setGeometry(_DESKTOP_OFFSET_LEFT, _DESKTOP_OFFSET_TOP, width, rect.height())
403247
function (e){

    var
      d = document,
      b = d.body,
      de = d.documentElement,
      axes = this.axes,
      plotOffset = this.plotOffset,
      lastMousePos = this.lastMousePos,
      pointer = E.eventPointer(e),
      dx = pointer.x - lastMousePos.pageX,
      dy = pointer.y - lastMousePos.pageY,
      r, rx, ry;

    if ('ontouchstart' in this.el) {
      r = D.position(this.overlay);
      rx = pointer.x - r.left - plotOffset.left;
      ry = pointer.y - r.top - plotOffset.top;
    } else {
      r = this.overlay.getBoundingClientRect();
      rx = e.clientX - r.left - plotOffset.left - b.scrollLeft - de.scrollLeft;
      ry = e.clientY - r.top - plotOffset.top - b.scrollTop - de.scrollTop;
    }

    return {
      x:  axes.x.p2d(rx),
      x2: axes.x2.p2d(rx),
      y:  axes.y.p2d(ry),
      y2: axes.y2.p2d(ry),
      relX: rx,
      relY: ry,
      dX: dx,
      dY: dy,
      absX: pointer.x,
      absY: pointer.y,
      pageX: pointer.x,
      pageY: pointer.y
    };
  }
1303824
def _on_move(self, event):
        """"""
        w = self.winfo_width()
        x = min(max(event.x, 0), w)
        self.coords('cursor', x, 0, x, self.winfo_height())
        self._variable.set(round2((360. * x) / w))
262893
def set_cursor(self, x, y):
        
        curses.curs_set(1)
        self.screen.move(y, x)
1283857
function ensureCursorVisible(cm) {
    resolveScrollToPos(cm);
    var cur = cm.getCursor(), from = cur, to = cur;
    if (!cm.options.lineWrapping) {
      from = cur.ch ? Pos(cur.line, cur.ch - 1) : cur;
      to = Pos(cur.line, cur.ch + 1);
    }
    cm.curOp.scrollToPos = {from: from, to: to, margin: cm.options.cursorScrollMargin, isCursor: true};
  }
616691
def mousePressEvent(self, event):
        
        if self.scene is not None:
            x_in_scene = self.mapToScene(event.pos()).x()
            window_length = self.parent.value('window_length')
            window_start = int(floor(x_in_scene / window_length) *
                               window_length)
            if self.parent.notes.annot is not None:
                window_start = self.parent.notes.annot.get_epoch_start(
                        window_start)
            self.update_position(window_start)
29779
function Cursor() {
  // If true, cursor should be rendered to the right of the char at offset p-1
  // rather than at the left edge of the char at offset p. This can happen when
  // user presses the "end" key or clicks past the end of a line.
  this.rightEnd = false;

  // Used for tracking previous left position in pixels, needed to implement
  // up/down arrows.
  this.prevLeft = null;

  // Used for rendering. Row is also needed to implement up/down arrows.
  this.row = 0;   // row (line number)
  this.left = 0;  // left position, in pixels

  this.blinkTimer_ = 0;

  this.el_ = createDiv({
    position: 'absolute',
    width: '2px',
    backgroundColor: '#000',
    zIndex: '2'
  });

  window.setInterval((function() {
    if (this.blinkTimer_ === -1) return;
    this.blinkTimer_ = (this.blinkTimer_ + 1) % 10;
    // Visible 60% of the time, hidden 40% of the time.
    this.el_.style.visibility = (this.blinkTimer_ < 6) ? 'visible' : 'hidden';
  }).bind(this), 100);
}
959017
def _move_focus(pymux, get_x, get_y):
    "  "
    window = pymux.arrangement.get_active_window()

    try:
        write_pos = pymux.get_client_state().layout_manager.pane_write_positions[window.active_pane]
    except KeyError:
        pass
    else:
        x = get_x(write_pos)
        y = get_y(write_pos)

        # Look for the pane at this position.
        for pane, wp in pymux.get_client_state().layout_manager.pane_write_positions.items():
            if (wp.xpos <= x < wp.xpos + wp.width and
                    wp.ypos <= y < wp.ypos + wp.height):
                window.active_pane = pane
                return
1302539
function(axis, delta) {

		var panFriction,
			overDiff = 0,
			newOffset = _panOffset[axis] + delta[axis],
			startOverDiff,
			dir = delta[axis] > 0,
			newMainScrollPosition = _mainScrollPos.x + delta.x,
			mainScrollDiff = _mainScrollPos.x - _startMainScrollPos.x,
			newPanPos,
			newMainScrollPos;

		// calculate fdistance over the bounds and friction
		if(newOffset > _currPanBounds.min[axis] || newOffset < _currPanBounds.max[axis]) {
			panFriction = _options.panEndFriction;
			// Linear increasing of friction, so at 1/4 of viewport it's at max value. 
			// Looks not as nice as was expected. Left for history.
			// panFriction = (1 - (_panOffset[axis] + delta[axis] + panBounds.min[axis]) / (_viewportSize[axis] / 4) );
		} else {
			panFriction = 1;
		}
		
		newOffset = _panOffset[axis] + delta[axis] * panFriction;

		// move main scroll or start panning
		if(_options.allowPanToNext || _currZoomLevel === self.currItem.initialZoomLevel) {


			if(!_currZoomElementStyle) {
				
				newMainScrollPos = newMainScrollPosition;

			} else if(_direction === 'h' && axis === 'x' && !_zoomStarted ) {
				
				if(dir) {
					if(newOffset > _currPanBounds.min[axis]) {
						panFriction = _options.panEndFriction;
						overDiff = _currPanBounds.min[axis] - newOffset;
						startOverDiff = _currPanBounds.min[axis] - _startPanOffset[axis];
					}
					
					// drag right
					if( (startOverDiff <= 0 || mainScrollDiff < 0) && _getNumItems() > 1 ) {
						newMainScrollPos = newMainScrollPosition;
						if(mainScrollDiff < 0 && newMainScrollPosition > _startMainScrollPos.x) {
							newMainScrollPos = _startMainScrollPos.x;
						}
					} else {
						if(_currPanBounds.min.x !== _currPanBounds.max.x) {
							newPanPos = newOffset;
						}
						
					}

				} else {

					if(newOffset < _currPanBounds.max[axis] ) {
						panFriction =_options.panEndFriction;
						overDiff = newOffset - _currPanBounds.max[axis];
						startOverDiff = _startPanOffset[axis] - _currPanBounds.max[axis];
					}

					if( (startOverDiff <= 0 || mainScrollDiff > 0) && _getNumItems() > 1 ) {
						newMainScrollPos = newMainScrollPosition;

						if(mainScrollDiff > 0 && newMainScrollPosition < _startMainScrollPos.x) {
							newMainScrollPos = _startMainScrollPos.x;
						}

					} else {
						if(_currPanBounds.min.x !== _currPanBounds.max.x) {
							newPanPos = newOffset;
						}
					}

				}


				//
			}

			if(axis === 'x') {

				if(newMainScrollPos !== undefined) {
					_moveMainScroll(newMainScrollPos, true);
					if(newMainScrollPos === _startMainScrollPos.x) {
						_mainScrollShifted = false;
					} else {
						_mainScrollShifted = true;
					}
				}

				if(_currPanBounds.min.x !== _currPanBounds.max.x) {
					if(newPanPos !== undefined) {
						_panOffset.x = newPanPos;
					} else if(!_mainScrollShifted) {
						_panOffset.x += delta.x * panFriction;
					}
				}

				return newMainScrollPos !== undefined;
			}

		}

		if(!_mainScrollAnimating) {
			
			if(!_mainScrollShifted) {
				if(_currZoomLevel > self.currItem.fitRatio) {
					_panOffset[axis] += delta[axis] * panFriction;
				
				}
			}

			
		}
		
	}
76813
def _onShortcutSelectAndScroll(self, down):
        
        cursor = self.textCursor()
        cursor.movePosition(QTextCursor.Down if down else QTextCursor.Up, QTextCursor.KeepAnchor)
        self.setTextCursor(cursor)
        self._onShortcutScroll(down)
1070490
private int findSpanEnd(TextCursor cursor, int spanStart, int limit, char span) {
        for (int i = spanStart + 1; i < limit; i++) {
            char c = cursor.text.charAt(i);
            if (c == span) {
                // Check prev and next symbols
                if (isGoodAnchor(cursor.text, i + 1) && isNotSymbol(cursor.text, i - 1, span)) {
                    return i + 1;
                }
            }
        }
        return -1;
    }
1152485
def OnZoomStandard(self, event):
        """"""

        self.grid.actions.zoom(zoom=1.0)

        event.Skip()
1043904
def end_of_line(event):
    "  "
    buff = event.current_buffer
    buff.cursor_position += buff.document.get_end_of_line_position()