Exemplo n.º 1
0
func (i *cli) ReadString(delim byte) (line string, err error) {
	system.SetForegroundGroup(system.Pgid())

	uncooked.ApplyMode()
	defer cooked.ApplyMode()

	command := cell.List(
		cell.Cons(
			cell.NewSymbol("_sys_"),
			cell.NewSymbol("get-prompt"),
		),
		cell.NewSymbol("> "),
	)
	prompt := task.Call(nil, command, "")

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

	if err == liner.ErrPromptAborted {
		return line, cell.ErrCtrlCPressed
	}

	return
}
Exemplo n.º 2
0
Arquivo: ui.go Projeto: 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
}