示例#1
0
func (r *Reader) feed(src io.Reader) {
	delim := byte('\n')
	if r.delimNil {
		delim = '\000'
	}
	reader := bufio.NewReaderSize(src, readerBufferSize)
	for {
		// ReadBytes returns err != nil if and only if the returned data does not
		// end in delim.
		bytea, err := reader.ReadBytes(delim)
		byteaLen := len(bytea)
		if len(bytea) > 0 {
			if err == nil {
				// get rid of carriage return if under Windows:
				if util.IsWindows() && byteaLen >= 2 && bytea[byteaLen-2] == byte('\r') {
					bytea = bytea[:byteaLen-2]
				} else {
					bytea = bytea[:byteaLen-1]
				}
			}
			if r.pusher(bytea) {
				r.eventBox.Set(EvtReadNew, nil)
			}
		}
		if err != nil {
			break
		}
	}
}
示例#2
0
文件: options.go 项目: junegunn/fzf
func parseHeight(str string) sizeSpec {
	if util.IsWindows() {
		errorExit("--height options is currently not supported on Windows")
	}
	size := parseSize(str, 100, "height")
	return size
}
示例#3
0
func quoteEntry(entry string) string {
	if util.IsWindows() {
		return strconv.Quote(strings.Replace(entry, "\"", "\\\"", -1))
	}
	return "'" + strings.Replace(entry, "'", "'\\''", -1) + "'"
}