示例#1
0
文件: ui.go 项目: thewhitetulip/oh
func (i *cli) ReadString(delim byte) (line string, err error) {
	task.SetForegroundGroup(task.Pgid())

	uncooked.ApplyMode()
	defer cooked.ApplyMode()

	if line, err = i.State.Prompt(task.Pgid(), "> "); err == nil {
		i.AppendHistory(line)
		if task.ForegroundTask().Job.Command == "" {
			task.ForegroundTask().Job.Command = line
		}
		line += "\n"
	}
	return
}
示例#2
0
文件: ui.go 项目: ivanfoo/oh
func restart(err error) bool {
	if err == io.EOF {
		return false
	}

	g := task.Pgid()
	if g > 0 {
		syscall.Syscall(syscall.SYS_IOCTL,
			uintptr(syscall.Stdin),
			syscall.TIOCSPGRP,
			uintptr(unsafe.Pointer(&g)))
	}

	return true
}
示例#3
0
文件: ui.go 项目: ivanfoo/oh
func (i *cli) ReadString(delim byte) (line string, err error) {
	task.SetForegroundGroup(task.Pgid())

	uncooked.ApplyMode()
	defer cooked.ApplyMode()

	t := task.ForegroundTask()

	command := cell.List(
		cell.Cons(cell.NewSymbol("sys"), cell.NewSymbol("get-prompt")),
		cell.NewSymbol("> "),
	)
	prompt := t.Call(command)

	if line, err = i.State.Prompt(prompt); err == nil {
		i.AppendHistory(line)
		if t.Job.Command == "" {
			t.Job.Command = line
		}
		line += "\n"
	}
	return
}