// Buffer a rune without moving the cursor.
768393
func (r *tokenReader) buffer() (rune, error) {
	rn, _, err := r.r.ReadRune()
	if err != nil {
		return 0, err
	}
	r.runes = append(r.runes, rn)
	return rn, nil
}
811045
func (w *eventWorker) bufferFunc(msg *evMsg) (stop bool) {
	var lastTokenSeen = msg.token
	w.processMsg(msg)
outer:
	for len(w.buffer) < w.batchSize {
		select {
		case msg = <-w.input:
			if msg.token != lastTokenSeen {
				// if the token changes, then emit what ever is in the buffer before proceeding
				w.emit(lastTokenSeen)
				lastTokenSeen = msg.token
			}
			w.processMsg(msg)
		default:
			break outer // emit what ever is in the buffer if there are no more datapoints to read
		}
	}
	// emit the data in the buffer
	w.emit(msg.token)
	return
}
1240033
func (g *Geometry) Buffer(d float64) (*Geometry, error) {
	const quadsegs = 8
	return geomFromC("Buffer", cGEOSBuffer(g.g, C.double(d), quadsegs))
}
1009160
func (rb *reorderBuffer) appendRune(r rune) {
	bn := rb.nbyte
	sz := utf8.EncodeRune(rb.byte[bn:], rune(r))
	rb.nbyte += utf8.UTFMax
	rb.rune[rb.nrune] = Properties{pos: bn, size: uint8(sz)}
	rb.nrune++
}
803361
func (lx *lexer) peek() rune {
	r := lx.next()
	lx.backup()
	return r
}
865758
func (d *Decoder) Buffered() io.Reader {
	return bytes.NewReader(d.buffer.Bytes())
}
438074
func (z *StreamLexer) PeekRune(pos int) (rune, int) {
	// from unicode/utf8
	c := z.Peek(pos)
	if c < 0xC0 {
		return rune(c), 1
	} else if c < 0xE0 {
		return rune(c&0x1F)<<6 | rune(z.Peek(pos+1)&0x3F), 2
	} else if c < 0xF0 {
		return rune(c&0x0F)<<12 | rune(z.Peek(pos+1)&0x3F)<<6 | rune(z.Peek(pos+2)&0x3F), 3
	}
	return rune(c&0x07)<<18 | rune(z.Peek(pos+1)&0x3F)<<12 | rune(z.Peek(pos+2)&0x3F)<<6 | rune(z.Peek(pos+3)&0x3F), 4
}
811650
func (l *StringLexer) Peek() (r rune) {
	r = l.Next()
	l.Backup()
	return r
}
595291
func (lx *lexer) skip(pred func(rune) bool) {
	for {
		r := lx.next()
		if pred(r) {
			continue
		}
		lx.backup()
		lx.ignore()
		return
	}
}
971344
func (b *Buffer) CursorRight(count int) {
	l := b.Document().GetCursorRightPosition(count)
	b.cursorPosition += l
	return
}
751367
func (l *ReaderLexer) Peek() (r rune) {
	guard := Mark("Peek")
	defer func() {
		Trace("return = %q", r)
		guard()
	}()

	r = l.Next()
	l.Backup()
	return r
}
913778
func (ei *escapeInterpreter) runes() []rune {
	switch ei.state {
	case stateNone:
		return []rune{0x1b}
	case stateEscape:
		return []rune{0x1b, ei.curch}
	case stateCSI:
		return []rune{0x1b, '[', ei.curch}
	case stateParams:
		ret := []rune{0x1b, '['}
		for _, s := range ei.csiParam {
			ret = append(ret, []rune(s)...)
			ret = append(ret, ';')
		}
		return append(ret, ei.curch)
	}
	return nil
}
449615
func (r *RuneBuffer) MoveToLineEnd() {
	for i := r.idx; i < len(r.buf)-1; i++ {
		if r.buf[i] == '\n' {
			r.idx = i
			return
		}
	}
	r.idx = len(r.buf)
}
817525
func (b *BufReader) Buffered() int {
	d := b.w - b.r
	if b.available != -1 && d > b.available {
		return b.available
	}
	return d
}
582091
func Runes(a, b []rune) []Change {
	return Diff(len(a), len(b), &runes{a, b})
}
361169
func (l *lexer) unread(r ...rune) {
	// ignore EOF runes
	_r := make([]rune, 0)
	for _, _rune := range r {
		if _rune != _EOF {
			_r = append(_r, _rune)
		}
	}

	// initialise the unread rune list if necessary
	if l._unread == nil {
		l._unread = make([]rune, 0)
	}
	if len(_r) != 0 {
		l._unread = append(l._unread, _r...)
	}

	// decrement the offset and column counts
	//      - we have to take care of column being 0
	//      - at present we can only unwind across a single line boundary
	_length := len(_r)
	for ; _length > 0; _length-- {
		l._offset--
		if l._column == 1 {
			_length := len(l._previous)
			if _length > 0 {
				l._column = l._previous[_length-1]
				l._previous = l._previous[:_length-1]
				l._line--
			}
		} else {
			l._column--
		}
	}
}
1139370
func ToASCII(r rune) rune {
	a, ok := UnicodeToASCII[r]
	if ok {
		return a
	}
	return r
}