cmd := exec.Command(inputCmd, args...)
outputBytes := &bytes.Buffer{}
-
- cmd.Stdout = outputBytes // send output to buffer
+ cmd.Stdout = outputBytes
+ cmd.Stderr = outputBytes
cmd.Start()
err := cmd.Wait() // wait for command to finish
outstring := outputBytes.String()
if err == nil {
messenger.Message(inputCmd, " exited without error")
} else {
- messenger.Message(inputCmd, " exited with error: ", err)
+ messenger.Message(inputCmd, " exited with error: ", err, ": ", output)
}
} else {
messenger.Message(output)
}()
} else {
screen.Fini()
+ screen = nil
args := strings.Split(input, " ")[1:]
found := false
for {
- match := regex.FindStringIndex(view.buf.text)
+ match := regex.FindStringIndex(view.Buf.String())
if match == nil {
break
}
found = true
if strings.Contains(flags, "c") {
- // // The 'check' flag was used
- // if messenger.YesNoPrompt("Perform replacement?") {
- // view.eh.Replace(match[0], match[1], replace)
- // } else {
- // continue
- // }
+ // The 'check' flag was used
+ Search(search, view, true)
+ view.Relocate()
+ Redraw(view)
+ choice, canceled := messenger.YesNoPrompt("Perform replacement? (y,n)")
+ if canceled {
+ if view.Cursor.HasSelection() {
+ view.Cursor.SetLoc(view.Cursor.curSelection[0])
+ view.Cursor.ResetSelection()
+ }
+ messenger.Reset()
+ return
+ }
+ if choice {
+ view.Cursor.DeleteSelection()
+ view.Buf.Insert(match[0], replace)
+ view.Cursor.ResetSelection()
+ messenger.Reset()
+ } else {
+ if view.Cursor.HasSelection() {
+ searchStart = view.Cursor.curSelection[1]
+ } else {
+ searchStart = ToCharPos(view.Cursor.x, view.Cursor.y, view.Buf)
+ }
+ continue
+ }
+ } else {
+ view.Buf.Replace(match[0], match[1], replace)
}
- view.eh.Replace(match[0], match[1], replace)
}
if !found {
messenger.Message("Nothing matched " + search)