go-eol/readvt.go

25 lines
696 B
Go
Raw Normal View History

2024-03-26 06:05:26 +00:00
package eol
import (
"io"
"sourcecode.social/reiver/go-opt"
"sourcecode.social/reiver/go-eol/vt"
)
2024-03-26 06:24:08 +00:00
// ReadVT tries to read the "\v" (i.e., carriage-return) end-of-line sequence.
2024-03-26 06:05:26 +00:00
//
2024-03-26 06:24:08 +00:00
// If successful, it returns the number-of-bytes read (to read in end-of-line sequence "\v").
2024-03-26 06:05:26 +00:00
//
2024-03-26 06:24:08 +00:00
// If the character read is not a '\v', then ReadVT will try to unread the character.
2024-03-26 06:05:26 +00:00
//
// Example usage:
//
// size, err := eol.ReadVT(runescanner)
func ReadVT(runescanner io.RuneScanner) (size int, err error) {
const characterNumber uint64 = 1
var circumstance internalCircumstance = specifyCircumstance(opt.Something(vt.String), characterNumber)
return readthisrune(circumstance, runescanner, vt.Rune)
}