// forward moves the cursor one character forward.
// Returns a boolean to know if the cursor is at the end of the line.
541786
func (b *buffer) forward() (end bool, err error) {
	if b.pos == b.size {
		return true, nil
	}
	b.pos++

	if _, col := b.pos2xy(b.pos); col != 0 {
		if _, err = term.Output.Write(CursorForward); err != nil {
			return false, outputError(err.Error())
		}
	} else {
		if _, err = term.Output.Write(ToNextLine); err != nil {
			return false, outputError(err.Error())
		}
	}
	return
}
136413
func (c *PrefixCursor) Continue(val []byte) bool {
	return val != nil && bytes.HasPrefix(val, c.Prefix)
}
22159
func (c *Cursor) Move(x int, y int) {
	fmt.Fprintf(c.Out, "\x1b[%d;%df", x, y)
}
1252796
func (l *ReaderLexer) Next() (r rune) {
	/* Illustrated guide to how the cursors move:

	              pos
	              |
	              v
	buf | a | b | c |
	              ^
	              |
	              peekLoc

	-> l.Nex() -> returns d

	                  pos
	                  |
	                  v
	buf | a | b | c | d |
	                  ^
	                  |
	                  peekLoc


	-> l.Peek() -> returns e

	                  pos
	                  |
	                  v
	buf | a | b | c | d | e |
	                      ^
	                      |
	                      peekLoc

	-> l.Backup()
	-> l.Backup()

	              pos
	              |
	              v
	buf | a | b | c | d | e |
	              ^
	              |
	              peekLoc

	-> l.Next() -> returns c

	                  pos
	                  |
	                  v
	buf | a | b | c | d | e |
	                  ^
	                  |
	                  peekLoc

	-> l.Next() -> returns d

	                      pos
	                      |
	                      v
	buf | a | b | c | d | e |
	                      ^
	                      |
	                      peekLoc
	*/
	guard := Mark("Next")
	defer func() {
		Trace("return = %q", r)
		guard()
	}()

	if l.pos == -1 || len(l.buf) == l.peekLoc+1 {
		r, _, err := l.source.ReadRune()
		switch err {
		case nil:
			l.peekLoc++
			l.pos++
			l.buf = append(l.buf, r)
		case io.EOF:
			l.peekLoc++
			l.pos++
			r = -1
			if l.buf[len(l.buf)-1] != r {
				l.buf = append(l.buf, r)
			}
		}
	} else {
		l.peekLoc++
		l.pos++
	}

	loc := l.peekLoc

	if loc < 0 || len(l.buf) <= loc {
		return EOF
		//    panic(fmt.Sprintf("FATAL: loc = %d, l.buf = %q (len = %d)", loc, l.buf, len(l.buf)))
	}

	Trace("l.buf = %q, loc = %d", l.buf, loc)
	return l.buf[loc]
}
715525
func (v *View) MoveCursor(dx, dy int, writeMode bool) {
	maxX, maxY := v.Size()
	cx, cy := v.cx+dx, v.cy+dy
	x, y := v.ox+cx, v.oy+cy

	var curLineWidth, prevLineWidth int
	// get the width of the current line
	if writeMode {
		if v.Wrap {
			curLineWidth = maxX - 1
		} else {
			curLineWidth = maxInt
		}
	} else {
		if y >= 0 && y < len(v.viewLines) {
			curLineWidth = len(v.viewLines[y].line)
			if v.Wrap && curLineWidth >= maxX {
				curLineWidth = maxX - 1
			}
		} else {
			curLineWidth = 0
		}
	}
	// get the width of the previous line
	if y-1 >= 0 && y-1 < len(v.viewLines) {
		prevLineWidth = len(v.viewLines[y-1].line)
	} else {
		prevLineWidth = 0
	}

	// adjust cursor's x position and view's x origin
	if x > curLineWidth { // move to next line
		if dx > 0 { // horizontal movement
			cy++
			if writeMode || v.oy+cy < len(v.viewLines) {
				if !v.Wrap {
					v.ox = 0
				}
				v.cx = 0
			}
		} else { // vertical movement
			if curLineWidth > 0 { // move cursor to the EOL
				if v.Wrap {
					v.cx = curLineWidth
				} else {
					ncx := curLineWidth - v.ox
					if ncx < 0 {
						v.ox += ncx
						if v.ox < 0 {
							v.ox = 0
						}
						v.cx = 0
					} else {
						v.cx = ncx
					}
				}
			} else {
				if writeMode || v.oy+cy < len(v.viewLines) {
					if !v.Wrap {
						v.ox = 0
					}
					v.cx = 0
				}
			}
		}
	} else if cx < 0 {
		if !v.Wrap && v.ox > 0 { // move origin to the left
			v.ox += cx
			v.cx = 0
		} else { // move to previous line
			cy--
			if prevLineWidth > 0 {
				if !v.Wrap { // set origin so the EOL is visible
					nox := prevLineWidth - maxX + 1
					if nox < 0 {
						v.ox = 0
					} else {
						v.ox = nox
					}
				}
				v.cx = prevLineWidth
			} else {
				if !v.Wrap {
					v.ox = 0
				}
				v.cx = 0
			}
		}
	} else { // stay on the same line
		if v.Wrap {
			v.cx = cx
		} else {
			if cx >= maxX {
				v.ox += cx - maxX + 1
				v.cx = maxX
			} else {
				v.cx = cx
			}
		}
	}

	// adjust cursor's y position and view's y origin
	if cy < 0 {
		if v.oy > 0 {
			v.oy--
		}
	} else if writeMode || v.oy+cy < len(v.viewLines) {
		if cy >= maxY {
			v.oy++
		} else {
			v.cy = cy
		}
	}
}
610744
func (d *Driver) Forward(val int) error {
	d.cmdMutex.Lock()
	defer d.cmdMutex.Unlock()

	d.ry = float32(val) / 100.0
	return nil
}
319274
func (a *Driver) Forward(speed int) {
	a.adaptor().drone.Forward(speed)
}
9739
func (c *Cursor) PreviousLine(n int) {
	fmt.Fprintf(c.Out, "\x1b[%dF", n)
}
178701
func (c *Cursor) NextLine(n int) {
	fmt.Fprintf(c.Out, "\x1b[%dE", n)
}
701929
func (c *cursor) Next() (key, value []byte) {
	return (*bbolt.Cursor)(c).Next()
}
1207275
func (it *IterLong) Next() bool {

	if it.err != nil || it.finished {
		return false
	}

	var first bool
	if it.t == 0 {
		it.t = it.T0
		first = true
	}

	// read delta-of-delta
	dod, ok := it.dod()
	if !ok {
		return false
	}

	it.tDelta += uint32(dod)
	it.t = it.t + it.tDelta

	if first {
		// first point. read the float raw
		v, err := it.br.readBits(64)
		if err != nil {
			it.err = err
			return false
		}

		it.val = math.Float64frombits(v)
		return true
	}

	// read compressed value
	bit, err := it.br.readBit()
	if err != nil {
		it.err = err
		return false
	}

	if bit == zero {
		// it.val = it.val
	} else {
		bit, itErr := it.br.readBit()
		if itErr != nil {
			it.err = err
			return false
		}
		if bit == zero {
			// reuse leading/trailing zero bits
			// it.leading, it.trailing = it.leading, it.trailing
		} else {
			bits, err := it.br.readBits(5)
			if err != nil {
				it.err = err
				return false
			}
			it.leading = uint8(bits)

			bits, err = it.br.readBits(6)
			if err != nil {
				it.err = err
				return false
			}
			mbits := uint8(bits)
			// 0 significant bits here means we overflowed and we actually need 64; see comment in encoder
			if mbits == 0 {
				mbits = 64
			}
			it.trailing = 64 - it.leading - mbits
		}

		mbits := int(64 - it.leading - it.trailing)
		bits, err := it.br.readBits(mbits)
		if err != nil {
			it.err = err
			return false
		}
		vbits := math.Float64bits(it.val)
		vbits ^= (bits << it.trailing)
		it.val = math.Float64frombits(vbits)
	}

	return true
}
527157
func (e *Exchange) Forward(ctx context.Context, envelope *events.Envelope) (err error) {
	if err := validateEnvelope(envelope); err != nil {
		return err
	}

	defer func() {
		logger := log.G(ctx).WithFields(logrus.Fields{
			"topic": envelope.Topic,
			"ns":    envelope.Namespace,
			"type":  envelope.Event.TypeUrl,
		})

		if err != nil {
			logger.WithError(err).Error("error forwarding event")
		} else {
			logger.Debug("event forwarded")
		}
	}()

	return e.broadcaster.Write(envelope)
}
1334372
func (it *Iter) Next() bool {
	if len(it.values) == 0 && it.meta.HasMore && !it.listParams.Single {
		// determine if we're moving forward or backwards in paging
		if it.listParams.EndingBefore != nil {
			it.listParams.EndingBefore = String(listItemID(it.cur))
			it.formValues.Set(EndingBefore, *it.listParams.EndingBefore)
		} else {
			it.listParams.StartingAfter = String(listItemID(it.cur))
			it.formValues.Set(StartingAfter, *it.listParams.StartingAfter)
		}
		it.getPage()
	}
	if len(it.values) == 0 {
		return false
	}
	it.cur = it.values[0]
	it.values = it.values[1:]
	return true
}
452344
func (rp *Ringpop) Forward(dest string, keys []string, request []byte, service, endpoint string,
	format tchannel.Format, opts *forward.Options) ([]byte, error) {

	return rp.forwarder.ForwardRequest(request, dest, service, endpoint, keys, format, opts)
}
1082253
func (r *RuneBuffer) MoveToLineStart() {
	for i := r.idx; i > 0; i-- {
		if r.buf[i-1] == '\n' {
			r.idx = i
			return
		}
	}
	r.idx = 0
}
937921
func (p *Parser) advance() bool {
	r := p.next()
	if r == '\\' {
		p.next()
	} else if isTerminator(r) {
		p.backup()
		return false
	}
	return true
}
362675
func HasNewline(ctx context.Context) bool {
	bv, ok := ctx.Value(ctxKeyNewline).(bool)
	if !ok {
		return true
	}
	return bv
}