multiline

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2023 License: MIT Imports: 6 Imported by: 5

README

go-multiline-ny

This is the readline package supporting multi-lines that extends go-readline-ny

image

package main

import (
    "context"
    "fmt"
    "os"

    "github.com/hymkor/go-multiline-ny"
)

func main() {
    ctx := context.Background()
    fmt.Println("Enter, DOWN or Ctrl-N: New line or move to the next line")
    fmt.Println("UP or Ctrl-P: Move to the previous line.")
    fmt.Println("Ctrl-Enter: Submit")
    fmt.Println("Ctrl-C: Cancel lines.")
    fmt.Println("Ctrl-D: Quit.")
    for {
        lines, err := multiline.Read(ctx)
        if err != nil {
            fmt.Fprintln(os.Stderr, err.Error())
            return
        }
        fmt.Println("-----")
        for len(lines) > 0 && lines[len(lines)-1] == "" {
            lines = lines[:len(lines)-1]
        }
        for _, s := range lines {
            fmt.Println(s)
        }
        fmt.Println("-----")
    }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Read

func Read(ctx context.Context) ([]string, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL