From 2117a3747b102bef473a7731cee2af821f96d49f Mon Sep 17 00:00:00 2001 From: sammy-ette Date: Thu, 12 Jun 2025 22:32:04 -0400 Subject: [PATCH] feat: move readline to golibs --- cmd/docgen/docgen.go | 172 +++++++-------- docs/api/hilbish/_index.md | 64 ------ docs/api/hilbish/hilbish.abbr.md | 67 ------ docs/api/hilbish/hilbish.editor.md | 124 ----------- docs/api/hilbish/hilbish.history.md | 102 --------- docs/api/hilbish/hilbish.jobs.md | 146 ------------- docs/api/hilbish/hilbish.messages.md | 135 ------------ docs/api/hilbish/hilbish.module.md | 73 ------- docs/api/hilbish/hilbish.os.md | 20 -- docs/api/hilbish/hilbish.runner.md | 171 --------------- docs/api/hilbish/hilbish.timers.md | 100 --------- docs/api/readline.md | 38 ++++ emmyLuaDocs/readline.lua | 5 + {readline => golibs/readline}/CHANGES.md | 0 {readline => golibs/readline}/LICENSE | 0 {readline => golibs/readline}/README.md | 0 {readline => golibs/readline}/codes.go | 0 {readline => golibs/readline}/comp-grid.go | 0 {readline => golibs/readline}/comp-group.go | 0 {readline => golibs/readline}/comp-list.go | 0 {readline => golibs/readline}/comp-map.go | 0 {readline => golibs/readline}/cursor.go | 0 {readline => golibs/readline}/editor.go | 0 {readline => golibs/readline}/editor_plan9.go | 0 {readline => golibs/readline}/editor_unix.go | 0 .../readline}/editor_windows.go | 0 {readline => golibs/readline}/errors.go | 0 {readline => golibs/readline}/events.go | 0 {readline => golibs/readline}/go.mod | 0 {readline => golibs/readline}/go.sum | 0 {readline => golibs/readline}/godoc.go | 0 {readline => golibs/readline}/hint.go | 0 {readline => golibs/readline}/history.go | 0 {readline => golibs/readline}/info.go | 0 {readline => golibs/readline}/instance.go | 0 {readline => golibs/readline}/line.go | 0 {readline => golibs/readline}/line_test.go | 0 {readline => golibs/readline}/prompt.go | 0 {readline => golibs/readline}/raw_bsd.go | 0 {readline => golibs/readline}/raw_linux.go | 0 {readline => golibs/readline}/raw_plan9.go | 0 {readline => golibs/readline}/raw_solaris.go | 0 {readline => golibs/readline}/raw_unix.go | 0 {readline => golibs/readline}/raw_windows.go | 0 {readline => golibs/readline}/readline.go | 0 {readline => golibs/readline}/register.go | 0 {readline => golibs/readline}/syntax.go | 0 {readline => golibs/readline}/tab-virtual.go | 0 {readline => golibs/readline}/tab.go | 0 {readline => golibs/readline}/tabfind.go | 0 {readline => golibs/readline}/term.go | 0 {readline => golibs/readline}/timer.go | 0 {readline => golibs/readline}/tokenise.go | 0 {readline => golibs/readline}/tui-effects.go | 0 {readline => golibs/readline}/undo.go | 0 {readline => golibs/readline}/update.go | 0 {readline => golibs/readline}/vim.go | 0 {readline => golibs/readline}/vimdelete.go | 0 {readline => golibs/readline}/wrap.go | 0 readline/raw/LICENSE | 201 ------------------ readline/raw/README.md | 10 - readline/raw/main.go | 22 -- 62 files changed, 130 insertions(+), 1320 deletions(-) delete mode 100644 docs/api/hilbish/hilbish.abbr.md delete mode 100644 docs/api/hilbish/hilbish.editor.md delete mode 100644 docs/api/hilbish/hilbish.history.md delete mode 100644 docs/api/hilbish/hilbish.jobs.md delete mode 100644 docs/api/hilbish/hilbish.messages.md delete mode 100644 docs/api/hilbish/hilbish.module.md delete mode 100644 docs/api/hilbish/hilbish.os.md delete mode 100644 docs/api/hilbish/hilbish.timers.md create mode 100644 docs/api/readline.md create mode 100644 emmyLuaDocs/readline.lua rename {readline => golibs/readline}/CHANGES.md (100%) rename {readline => golibs/readline}/LICENSE (100%) rename {readline => golibs/readline}/README.md (100%) rename {readline => golibs/readline}/codes.go (100%) rename {readline => golibs/readline}/comp-grid.go (100%) rename {readline => golibs/readline}/comp-group.go (100%) rename {readline => golibs/readline}/comp-list.go (100%) rename {readline => golibs/readline}/comp-map.go (100%) rename {readline => golibs/readline}/cursor.go (100%) rename {readline => golibs/readline}/editor.go (100%) rename {readline => golibs/readline}/editor_plan9.go (100%) rename {readline => golibs/readline}/editor_unix.go (100%) rename {readline => golibs/readline}/editor_windows.go (100%) rename {readline => golibs/readline}/errors.go (100%) rename {readline => golibs/readline}/events.go (100%) rename {readline => golibs/readline}/go.mod (100%) rename {readline => golibs/readline}/go.sum (100%) rename {readline => golibs/readline}/godoc.go (100%) rename {readline => golibs/readline}/hint.go (100%) rename {readline => golibs/readline}/history.go (100%) rename {readline => golibs/readline}/info.go (100%) rename {readline => golibs/readline}/instance.go (100%) rename {readline => golibs/readline}/line.go (100%) rename {readline => golibs/readline}/line_test.go (100%) rename {readline => golibs/readline}/prompt.go (100%) rename {readline => golibs/readline}/raw_bsd.go (100%) rename {readline => golibs/readline}/raw_linux.go (100%) rename {readline => golibs/readline}/raw_plan9.go (100%) rename {readline => golibs/readline}/raw_solaris.go (100%) rename {readline => golibs/readline}/raw_unix.go (100%) rename {readline => golibs/readline}/raw_windows.go (100%) rename {readline => golibs/readline}/readline.go (100%) rename {readline => golibs/readline}/register.go (100%) rename {readline => golibs/readline}/syntax.go (100%) rename {readline => golibs/readline}/tab-virtual.go (100%) rename {readline => golibs/readline}/tab.go (100%) rename {readline => golibs/readline}/tabfind.go (100%) rename {readline => golibs/readline}/term.go (100%) rename {readline => golibs/readline}/timer.go (100%) rename {readline => golibs/readline}/tokenise.go (100%) rename {readline => golibs/readline}/tui-effects.go (100%) rename {readline => golibs/readline}/undo.go (100%) rename {readline => golibs/readline}/update.go (100%) rename {readline => golibs/readline}/vim.go (100%) rename {readline => golibs/readline}/vimdelete.go (100%) rename {readline => golibs/readline}/wrap.go (100%) delete mode 100644 readline/raw/LICENSE delete mode 100644 readline/raw/README.md delete mode 100644 readline/raw/main.go diff --git a/cmd/docgen/docgen.go b/cmd/docgen/docgen.go index 1521e0e0..3de2f18a 100644 --- a/cmd/docgen/docgen.go +++ b/cmd/docgen/docgen.go @@ -2,14 +2,14 @@ package main import ( "fmt" - "path/filepath" "go/ast" "go/doc" "go/parser" "go/token" + "os" + "path/filepath" "regexp" "strings" - "os" "sync" md "github.com/atsushinee/go-markdown-generator/doc" @@ -27,49 +27,49 @@ menu: ` type emmyPiece struct { - DocPiece *docPiece + DocPiece *docPiece Annotations []string - Params []string // we only need to know param name to put in function - FuncName string + Params []string // we only need to know param name to put in function + FuncName string } type module struct { - Types []docPiece - Docs []docPiece - Fields []docPiece - Properties []docPiece + Types []docPiece + Docs []docPiece + Fields []docPiece + Properties []docPiece ShortDescription string - Description string - ParentModule string - HasInterfaces bool - HasTypes bool + Description string + ParentModule string + HasInterfaces bool + HasTypes bool } -type param struct{ +type param struct { Name string Type string - Doc []string + Doc []string } type docPiece struct { - Doc []string - FuncSig string - FuncName string - Interfacing string + Doc []string + FuncSig string + FuncName string + Interfacing string ParentModule string - GoFuncName string - IsInterface bool - IsMember bool - IsType bool - Fields []docPiece - Properties []docPiece - Params []param - Tags map[string][]tag + GoFuncName string + IsInterface bool + IsMember bool + IsType bool + Fields []docPiece + Properties []docPiece + Params []param + Tags map[string][]tag } type tag struct { - id string - fields []string + id string + fields []string startIdx int } @@ -78,13 +78,13 @@ var interfaceDocs = make(map[string]module) var emmyDocs = make(map[string][]emmyPiece) var typeTable = make(map[string][]string) // [0] = parentMod, [1] = interfaces var prefix = map[string]string{ - "main": "hl", - "hilbish": "hl", - "fs": "f", + "main": "hl", + "hilbish": "hl", + "fs": "f", "commander": "c", - "bait": "b", - "terminal": "term", - "snail": "snail", + "bait": "b", + "terminal": "term", + "snail": "snail", } func getTagsAndDocs(docs string) (map[string][]tag, []string) { @@ -109,7 +109,7 @@ func getTagsAndDocs(docs string) (map[string][]tag, []string) { } else { if tagParts[0] == "example" { exampleIdx := tags["example"][0].startIdx - exampleCode := pts[exampleIdx+1:idx] + exampleCode := pts[exampleIdx+1 : idx] tags["example"][0].fields = exampleCode parts = strings.Split(strings.Replace(strings.Join(parts, "\n"), strings.TrimPrefix(strings.Join(exampleCode, "\n"), "#example\n"), "", -1), "\n") @@ -121,7 +121,7 @@ func getTagsAndDocs(docs string) (map[string][]tag, []string) { fleds = tagParts[2:] } tags[tagParts[0]] = append(tags[tagParts[0]], tag{ - id: tagParts[1], + id: tagParts[1], fields: fleds, }) } @@ -138,7 +138,7 @@ func docPieceTag(tagName string, tags map[string][]tag) []docPiece { for _, tag := range tags[tagName] { dps = append(dps, docPiece{ FuncName: tag.id, - Doc: tag.fields, + Doc: tag.fields, }) } @@ -169,16 +169,16 @@ func setupDocType(mod string, typ *doc.Type) *docPiece { if strings.HasPrefix(d, "---") { // TODO: document types in lua /* - emmyLine := strings.TrimSpace(strings.TrimPrefix(d, "---")) - emmyLinePieces := strings.Split(emmyLine, " ") - emmyType := emmyLinePieces[0] - if emmyType == "@param" { - em.Params = append(em.Params, emmyLinePieces[1]) - } - if emmyType == "@vararg" { - em.Params = append(em.Params, "...") // add vararg - } - em.Annotations = append(em.Annotations, d) + emmyLine := strings.TrimSpace(strings.TrimPrefix(d, "---")) + emmyLinePieces := strings.Split(emmyLine, " ") + emmyType := emmyLinePieces[0] + if emmyType == "@param" { + em.Params = append(em.Params, emmyLinePieces[1]) + } + if emmyType == "@vararg" { + em.Params = append(em.Params, "...") // add vararg + } + em.Annotations = append(em.Annotations, d) */ } else { typeDoc = append(typeDoc, d) @@ -191,16 +191,16 @@ func setupDocType(mod string, typ *doc.Type) *docPiece { } parentMod := mod dps := &docPiece{ - Doc: typeDoc, - FuncName: typeName, - Interfacing: interfaces, - IsInterface: inInterface, - IsMember: isMember, - IsType: true, + Doc: typeDoc, + FuncName: typeName, + Interfacing: interfaces, + IsInterface: inInterface, + IsMember: isMember, + IsType: true, ParentModule: parentMod, - Fields: fields, - Properties: properties, - Tags: tags, + Fields: fields, + Properties: properties, + Tags: tags, } typeTable[strings.ToLower(typeName)] = []string{parentMod, interfaces} @@ -221,6 +221,10 @@ func setupDoc(mod string, fun *doc.Func) *docPiece { goto start } + if prefix[mod] == "" { + return nil + } + if (!strings.HasPrefix(fun.Name, prefix[mod]) && tags["interface"] == nil) || (strings.ToLower(fun.Name) == "loader" && tags["interface"] == nil) { return nil } @@ -248,7 +252,7 @@ start: params[i] = param{ Name: p.id, Type: p.fields[0], - Doc: p.fields[1:], + Doc: p.fields[1:], } } } @@ -279,24 +283,24 @@ start: parentMod = mod } dps := &docPiece{ - Doc: funcdoc, - FuncSig: funcsig, - FuncName: funcName, - Interfacing: interfaces, - GoFuncName: strings.ToLower(fun.Name), - IsInterface: inInterface, - IsMember: isMember, + Doc: funcdoc, + FuncSig: funcsig, + FuncName: funcName, + Interfacing: interfaces, + GoFuncName: strings.ToLower(fun.Name), + IsInterface: inInterface, + IsMember: isMember, ParentModule: parentMod, - Fields: fields, - Properties: properties, - Params: params, - Tags: tags, + Fields: fields, + Properties: properties, + Params: params, + Tags: tags, } if strings.HasSuffix(dps.GoFuncName, strings.ToLower("loader")) { dps.Doc = parts } em.DocPiece = dps - + emmyDocs[mod] = append(emmyDocs[mod], em) return dps } @@ -326,11 +330,11 @@ provided by Hilbish. os.Mkdir("emmyLuaDocs", 0777) dirs := []string{"./", "./util"} - filepath.Walk("golibs/", func (path string, info os.FileInfo, err error) error { + filepath.Walk("golibs/", func(path string, info os.FileInfo, err error) error { if !info.IsDir() { return nil } - dirs = append(dirs, "./" + path) + dirs = append(dirs, "./"+path) return nil }) @@ -445,13 +449,13 @@ provided by Hilbish. docs[mod] = newDoc } else { docs[mod] = module{ - Types: filteredTypePieces, - Docs: filteredPieces, + Types: filteredTypePieces, + Docs: filteredPieces, ShortDescription: shortDesc, - Description: strings.Join(desc, "\n"), - HasInterfaces: hasInterfaces, - Properties: docPieceTag("property", tags), - Fields: docPieceTag("field", tags), + Description: strings.Join(desc, "\n"), + HasInterfaces: hasInterfaces, + Properties: docPieceTag("property", tags), + Fields: docPieceTag("field", tags), } } } @@ -466,7 +470,7 @@ provided by Hilbish. for mod, v := range docs { docPath := "docs/api/" + mod + ".md" if v.HasInterfaces { - os.Mkdir("docs/api/" + mod, 0777) + os.Mkdir("docs/api/"+mod, 0777) os.Remove(docPath) // remove old doc path if it exists docPath = "docs/api/" + mod + "/_index.md" } @@ -519,11 +523,11 @@ provided by Hilbish. continue } - mdTable.SetContent(i - diff, 0, fmt.Sprintf(`%s`, dps.FuncName, dps.FuncSig)) + mdTable.SetContent(i-diff, 0, fmt.Sprintf(`%s`, dps.FuncName, dps.FuncSig)) if len(dps.Doc) == 0 { fmt.Printf("WARNING! Function %s on module %s has no documentation!\n", dps.FuncName, modname) } else { - mdTable.SetContent(i - diff, 1, dps.Doc[0]) + mdTable.SetContent(i-diff, 1, dps.Doc[0]) } } f.WriteString(mdTable.String()) @@ -537,7 +541,6 @@ provided by Hilbish. mdTable.SetTitle(0, "") mdTable.SetTitle(1, "") - for i, dps := range modu.Fields { mdTable.SetContent(i, 0, dps.FuncName) mdTable.SetContent(i, 1, strings.Join(dps.Doc, " ")) @@ -552,7 +555,6 @@ provided by Hilbish. mdTable.SetTitle(0, "") mdTable.SetTitle(1, "") - for i, dps := range modu.Properties { mdTable.SetContent(i, 0, dps.FuncName) mdTable.SetContent(i, 1, strings.Join(dps.Doc, " ")) @@ -570,7 +572,7 @@ provided by Hilbish. continue } f.WriteString(fmt.Sprintf("
\n
", dps.FuncName)) - htmlSig := typeTag.ReplaceAllStringFunc(strings.Replace(modname + "." + dps.FuncSig, "<", `\<`, -1), func(typ string) string { + htmlSig := typeTag.ReplaceAllStringFunc(strings.Replace(modname+"."+dps.FuncSig, "<", `\<`, -1), func(typ string) string { typName := typ[1:] typLookup := typeTable[strings.ToLower(typName)] ifaces := typLookup[0] + "." + typLookup[1] + "/" @@ -657,7 +659,7 @@ provided by Hilbish. typName := regexp.MustCompile(`\w+`).FindString(typ[1:]) typLookup := typeTable[strings.ToLower(typName)] fmt.Printf("%+q, \n", typLookup) - linkedTyp := fmt.Sprintf("/Hilbish/docs/api/%s/%s/#%s", typLookup[0], typLookup[0] + "." + typLookup[1], strings.ToLower(typName)) + linkedTyp := fmt.Sprintf("/Hilbish/docs/api/%s/%s/#%s", typLookup[0], typLookup[0]+"."+typLookup[1], strings.ToLower(typName)) return fmt.Sprintf(`%s`, linkedTyp, typName) }) f.WriteString(fmt.Sprintf("#### %s\n", htmlSig)) diff --git a/docs/api/hilbish/_index.md b/docs/api/hilbish/_index.md index 5aa7045b..cfe107be 100644 --- a/docs/api/hilbish/_index.md +++ b/docs/api/hilbish/_index.md @@ -30,8 +30,6 @@ interfaces and functions which directly relate to shell functionality. |read(prompt) -> input (string)|Read input from the user, using Hilbish's line editor/input reader.| |timeout(cb, time) -> @Timer|Executed the `cb` function after a period of `time`.| |which(name) -> string|Checks if `name` is a valid command.| -|runnerMode(mode)|Sets the execution/runner mode for interactive Hilbish.| -|run(cmd, streams)|Runs `cmd` in Hilbish's shell script interpreter.| ## Static module fields ||| @@ -475,65 +473,3 @@ Writes data to a sink. #### writeln(str) Writes data to a sink with a newline at the end. -
-
-

-hilbish.run(cmd, streams) - - - -

- -Runs `cmd` in Hilbish's shell script interpreter. -The `streams` parameter specifies the output and input streams the command should use. -For example, to write command output to a sink. -As a table, the caller can directly specify the standard output, error, and input -streams of the command with the table keys `out`, `err`, and `input` respectively. -As a boolean, it specifies whether the command should use standard output or return its output streams. -#### Parameters -`cmd` **`string`** - - -`streams` **`table|boolean`** - - -#### Example -```lua --- This code is the same as `ls -l | wc -l` -local fs = require 'fs' -local pr, pw = fs.pipe() -hilbish.run('ls -l', { - stdout = pw, - stderr = pw, -}) -pw:close() -hilbish.run('wc -l', { - stdin = pr -}) -``` -
- -
-
-

-hilbish.runnerMode(mode) - - - -

- -Sets the execution/runner mode for interactive Hilbish. -**NOTE: This function is deprecated and will be removed in 3.0** -Use `hilbish.runner.setCurrent` instead. -This determines whether Hilbish wll try to run input as Lua -and/or sh or only do one of either. -Accepted values for mode are hybrid (the default), hybridRev (sh first then Lua), -sh, and lua. It also accepts a function, to which if it is passed one -will call it to execute user input instead. -Read [about runner mode](../features/runner-mode) for more information. -#### Parameters -`mode` **`string|function`** - - -
- diff --git a/docs/api/hilbish/hilbish.abbr.md b/docs/api/hilbish/hilbish.abbr.md deleted file mode 100644 index 8e88c190..00000000 --- a/docs/api/hilbish/hilbish.abbr.md +++ /dev/null @@ -1,67 +0,0 @@ ---- -title: Module hilbish.abbr -description: command line abbreviations -layout: doc -menu: - docs: - parent: "API" ---- - - -## Introduction -The abbr module manages Hilbish abbreviations. These are words that can be replaced -with longer command line strings when entered. -As an example, `git push` can be abbreviated to `gp`. When the user types -`gp` into the command line, after hitting space or enter, it will expand to `git push`. -Abbreviations can be used as an alternative to aliases. They are saved entirely in the history -Instead of the aliased form of the same command. - -## Functions -||| -|----|----| -|remove(abbr)|Removes the named `abbr`.| -|add(abbr, expanded|function, opts)|Adds an abbreviation. The `abbr` is the abbreviation itself,| -
-
-

-hilbish.abbr.add(abbr, expanded|function, opts) - - - -

- -Adds an abbreviation. The `abbr` is the abbreviation itself, -while `expanded` is what the abbreviation should expand to. -It can be either a function or a string. If it is a function, it will expand to what -the function returns. -`opts` is a table that accepts 1 key: `anywhere`. -`opts.anywhere` defines whether the abbr expands anywhere in the command line or not, -whereas the default behavior is only at the beginning of the line -#### Parameters -`abbr` **`string`** - - -`expanded|function` **`string`** - - -`opts` **`table`** - - -
- -
-
-

-hilbish.abbr.remove(abbr) - - - -

- -Removes the named `abbr`. -#### Parameters -`abbr` **`string`** - - -
- diff --git a/docs/api/hilbish/hilbish.editor.md b/docs/api/hilbish/hilbish.editor.md deleted file mode 100644 index 6dac64b8..00000000 --- a/docs/api/hilbish/hilbish.editor.md +++ /dev/null @@ -1,124 +0,0 @@ ---- -title: Module hilbish.editor -description: interactions for Hilbish's line reader -layout: doc -menu: - docs: - parent: "API" ---- - -## Introduction -The hilbish.editor interface provides functions to -directly interact with the line editor in use. - -## Functions -||| -|----|----| -|deleteByAmount(amount)|Deletes characters in the line by the given amount.| -|getLine() -> string|Returns the current input line.| -|getVimRegister(register) -> string|Returns the text that is at the register.| -|insert(text)|Inserts text into the Hilbish command line.| -|getChar() -> string|Reads a keystroke from the user. This is in a format of something like Ctrl-L.| -|setVimRegister(register, text)|Sets the vim register at `register` to hold the passed text.| - -
-
-

-hilbish.editor.deleteByAmount(amount) - - - -

- -Deletes characters in the line by the given amount. - -#### Parameters -`number` **`amount`** - - -
- -
-
-

-hilbish.editor.getLine() -> string - - - -

- -Returns the current input line. - -#### Parameters -This function has no parameters. -
- -
-
-

-hilbish.editor.getVimRegister(register) -> string - - - -

- -Returns the text that is at the register. - -#### Parameters -`string` **`register`** - - -
- -
-
-

-hilbish.editor.insert(text) - - - -

- -Inserts text into the Hilbish command line. - -#### Parameters -`string` **`text`** - - -
- -
-
-

-hilbish.editor.getChar() -> string - - - -

- -Reads a keystroke from the user. This is in a format of something like Ctrl-L. - -#### Parameters -This function has no parameters. -
- -
-
-

-hilbish.editor.setVimRegister(register, text) - - - -

- -Sets the vim register at `register` to hold the passed text. - -#### Parameters -`string` **`register`** - - -`string` **`text`** - - -
- diff --git a/docs/api/hilbish/hilbish.history.md b/docs/api/hilbish/hilbish.history.md deleted file mode 100644 index 6de9bdf4..00000000 --- a/docs/api/hilbish/hilbish.history.md +++ /dev/null @@ -1,102 +0,0 @@ ---- -title: Module hilbish.history -description: command history -layout: doc -menu: - docs: - parent: "API" ---- - -## Introduction -The history interface deals with command history. -This includes the ability to override functions to change the main -method of saving history. - -## Functions -||| -|----|----| -|add(cmd)|Adds a command to the history.| -|all() -> table|Retrieves all history as a table.| -|clear()|Deletes all commands from the history.| -|get(index)|Retrieves a command from the history based on the `index`.| -|size() -> number|Returns the amount of commands in the history.| - -
-
-

-hilbish.history.add(cmd) - - - -

- -Adds a command to the history. - -#### Parameters -`string` **`cmd`** - - -
- -
-
-

-hilbish.history.all() -> table - - - -

- -Retrieves all history as a table. - -#### Parameters -This function has no parameters. -
- -
-
-

-hilbish.history.clear() - - - -

- -Deletes all commands from the history. - -#### Parameters -This function has no parameters. -
- -
-
-

-hilbish.history.get(index) - - - -

- -Retrieves a command from the history based on the `index`. - -#### Parameters -`number` **`index`** - - -
- -
-
-

-hilbish.history.size() -> number - - - -

- -Returns the amount of commands in the history. - -#### Parameters -This function has no parameters. -
- diff --git a/docs/api/hilbish/hilbish.jobs.md b/docs/api/hilbish/hilbish.jobs.md deleted file mode 100644 index fe3978f6..00000000 --- a/docs/api/hilbish/hilbish.jobs.md +++ /dev/null @@ -1,146 +0,0 @@ ---- -title: Module hilbish.jobs -description: background job management -layout: doc -menu: - docs: - parent: "API" ---- - -## Introduction - -Manage interactive jobs in Hilbish via Lua. - -Jobs are the name of background tasks/commands. A job can be started via -interactive usage or with the functions defined below for use in external runners. - -## Functions -||| -|----|----| -|add(cmdstr, args, execPath)|Creates a new job. This function does not run the job. This function is intended to be| -|all() -> table[@Job]|Returns a table of all job objects.| -|disown(id)|Disowns a job. This simply deletes it from the list of jobs without stopping it.| -|get(id) -> @Job|Get a job object via its ID.| -|last() -> @Job|Returns the last added job to the table.| - -
-
-

-hilbish.jobs.add(cmdstr, args, execPath) - - - -

- -Creates a new job. This function does not run the job. This function is intended to be -used by runners, but can also be used to create jobs via Lua. Commanders cannot be ran as jobs. - -#### Parameters -`string` **`cmdstr`** -String that a user would write for the job - -`table` **`args`** -Arguments for the commands. Has to include the name of the command. - -`string` **`execPath`** -Binary to use to run the command. Needs to be an absolute path. - -#### Example -```lua -hilbish.jobs.add('go build', {'go', 'build'}, '/usr/bin/go') -``` -
- -
-
-

-hilbish.jobs.all() -> table[Job] - - - -

- -Returns a table of all job objects. - -#### Parameters -This function has no parameters. -
- -
-
-

-hilbish.jobs.disown(id) - - - -

- -Disowns a job. This simply deletes it from the list of jobs without stopping it. - -#### Parameters -`number` **`id`** - - -
- -
-
-

-hilbish.jobs.get(id) -> Job - - - -

- -Get a job object via its ID. - -#### Parameters -This function has no parameters. -
- -
-
-

-hilbish.jobs.last() -> Job - - - -

- -Returns the last added job to the table. - -#### Parameters -This function has no parameters. -
- -## Types -
- -## Job -The Job type describes a Hilbish job. -## Object properties -||| -|----|----| -|cmd|The user entered command string for the job.| -|running|Whether the job is running or not.| -|id|The ID of the job in the job table| -|pid|The Process ID| -|exitCode|The last exit code of the job.| -|stdout|The standard output of the job. This just means the normal logs of the process.| -|stderr|The standard error stream of the process. This (usually) includes error messages of the job.| - - -### Methods -#### background() -Puts a job in the background. This acts the same as initially running a job. - -#### foreground() -Puts a job in the foreground. This will cause it to run like it was -executed normally and wait for it to complete. - -#### start() -Starts running the job. - -#### stop() -Stops the job from running. - diff --git a/docs/api/hilbish/hilbish.messages.md b/docs/api/hilbish/hilbish.messages.md deleted file mode 100644 index 705cfa2c..00000000 --- a/docs/api/hilbish/hilbish.messages.md +++ /dev/null @@ -1,135 +0,0 @@ ---- -title: Module hilbish.messages -description: simplistic message passing -layout: doc -menu: - docs: - parent: "API" ---- - - -## Introduction -The messages interface defines a way for Hilbish-integrated commands, -user config and other tasks to send notifications to alert the user.z -The `hilbish.message` type is a table with the following keys: -`title` (string): A title for the message notification. -`text` (string): The contents of the message. -`channel` (string): States the origin of the message, `hilbish.*` is reserved for Hilbish tasks. -`summary` (string): A short summary of the `text`. -`icon` (string): Unicode (preferably standard emoji) icon for the message notification -`read` (boolean): Whether the full message has been read or not. - -## Functions -||| -|----|----| -|unreadCount()|Returns the amount of unread messages.| -|send(message)|Sends a message.| -|readAll()|Marks all messages as read.| -|read(idx)|Marks a message at `idx` as read.| -|delete(idx)|Deletes the message at `idx`.| -|clear()|Deletes all messages.| -|all()|Returns all messages.| -
-
-

-hilbish.messages.all() - - - -

- -Returns all messages. -#### Parameters -This function has no parameters. -
- -
-
-

-hilbish.messages.clear() - - - -

- -Deletes all messages. -#### Parameters -This function has no parameters. -
- -
-
-

-hilbish.messages.delete(idx) - - - -

- -Deletes the message at `idx`. -#### Parameters -`idx` **`number`** - - -
- -
-
-

-hilbish.messages.read(idx) - - - -

- -Marks a message at `idx` as read. -#### Parameters -`idx` **`number`** - - -
- -
-
-

-hilbish.messages.readAll() - - - -

- -Marks all messages as read. -#### Parameters -This function has no parameters. -
- -
-
-

-hilbish.messages.send(message) - - - -

- -Sends a message. -#### Parameters -`message` **`hilbish.message`** - - -
- -
-
-

-hilbish.messages.unreadCount() - - - -

- -Returns the amount of unread messages. -#### Parameters -This function has no parameters. -
- diff --git a/docs/api/hilbish/hilbish.module.md b/docs/api/hilbish/hilbish.module.md deleted file mode 100644 index 4029d7a7..00000000 --- a/docs/api/hilbish/hilbish.module.md +++ /dev/null @@ -1,73 +0,0 @@ ---- -title: Module hilbish.module -description: native module loading -layout: doc -menu: - docs: - parent: "API" ---- - -## Introduction - -The hilbish.module interface provides a function to load -Hilbish plugins/modules. Hilbish modules are Go-written -plugins (see https://pkg.go.dev/plugin) that are used to add functionality -to Hilbish that cannot be written in Lua for any reason. - -Note that you don't ever need to use the load function that is here as -modules can be loaded with a `require` call like Lua C modules, and the -search paths can be changed with the `paths` property here. - -To make a valid native module, the Go plugin has to export a Loader function -with a signature like so: `func(*rt.Runtime) rt.Value`. - -`rt` in this case refers to the Runtime type at -https://pkg.go.dev/github.com/arnodel/golua@master/runtime#Runtime - -Hilbish uses this package as its Lua runtime. You will need to read -it to use it for a native plugin. - -Here is some code for an example plugin: -```go -package main - -import ( - rt "github.com/arnodel/golua/runtime" -) - -func Loader(rtm *rt.Runtime) rt.Value { - return rt.StringValue("hello world!") -} -``` - -This can be compiled with `go build -buildmode=plugin plugin.go`. -If you attempt to require and print the result (`print(require 'plugin')`), it will show "hello world!" - -## Functions -||| -|----|----| -|load(path)|Loads a module at the designated `path`.| - -## Static module fields -||| -|----|----| -|paths|A list of paths to search when loading native modules. This is in the style of Lua search paths and will be used when requiring native modules. Example: `?.so;?/?.so`| - -
-
-

-hilbish.module.load(path) - - - -

- -Loads a module at the designated `path`. -It will throw if any error occurs. - -#### Parameters -`string` **`path`** - - -
- diff --git a/docs/api/hilbish/hilbish.os.md b/docs/api/hilbish/hilbish.os.md deleted file mode 100644 index 13b56b05..00000000 --- a/docs/api/hilbish/hilbish.os.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -title: Module hilbish.os -description: operating system info -layout: doc -menu: - docs: - parent: "API" ---- - -## Introduction -Provides simple text information properties about the current operating system. -This mainly includes the name and version. - -## Static module fields -||| -|----|----| -|family|Family name of the current OS| -|name|Pretty name of the current OS| -|version|Version of the current OS| - diff --git a/docs/api/hilbish/hilbish.runner.md b/docs/api/hilbish/hilbish.runner.md index 4ba49993..2e437984 100644 --- a/docs/api/hilbish/hilbish.runner.md +++ b/docs/api/hilbish/hilbish.runner.md @@ -55,15 +55,6 @@ end) ||| |----|----| |lua(cmd)|Evaluates `cmd` as Lua input. This is the same as using `dofile`| -|sh()|nil| -|setMode(mode)|**NOTE: This function is deprecated and will be removed in 3.0**| -|setCurrent(name)|Sets Hilbish's runner mode by name.| -|set(name, runner)|*Sets* a runner by name. The difference between this function and| -|run(input, priv)|Runs `input` with the currently set Hilbish runner.| -|getCurrent()|Returns the current runner by name.| -|get(name)|Get a runner by name.| -|exec(cmd, runnerName)|Executes `cmd` with a runner.| -|add(name, runner)|Adds a runner to the table of available runners.|
@@ -83,165 +74,3 @@ or `load`, but is appropriated for the runner interface.
-
-
-

-hilbish.runner.add(name, runner) - - - -

- -Adds a runner to the table of available runners. -If runner is a table, it must have the run function in it. -#### Parameters -`name` **`string`** - Name of the runner - -`runner` **`function|table`** - - -
- -
-
-

-hilbish.runner.exec(cmd, runnerName) - - - -

- -Executes `cmd` with a runner. -If `runnerName` is not specified, it uses the default Hilbish runner. -#### Parameters -`cmd` **`string`** - - -`runnerName` **`string?`** - - -
- -
-
-

-hilbish.runner.get(name) - - - -

- -Get a runner by name. -#### Parameters -`name` **`string`** - Name of the runner to retrieve. - -
- -
-
-

-hilbish.runner.getCurrent() - - - -

- -Returns the current runner by name. -#### Parameters -This function has no parameters. -
- -
-
-

-hilbish.runner.run(input, priv) - - - -

- -Runs `input` with the currently set Hilbish runner. -This method is how Hilbish executes commands. -`priv` is an optional boolean used to state if the input should be saved to history. -#### Parameters -`input` **`string`** - - -`priv` **`bool`** - - -
- -
-
-

-hilbish.runner.set(name, runner) - - - -

- -*Sets* a runner by name. The difference between this function and -add, is set will *not* check if the named runner exists. -The runner table must have the run function in it. -#### Parameters -`name` **`string`** - - -`runner` **`table`** - - -
- -
-
-

-hilbish.runner.setCurrent(name) - - - -

- -Sets Hilbish's runner mode by name. -#### Parameters -`name` **`string`** - - -
- -
-
-

-hilbish.runner.setMode(mode) - - - -

- -**NOTE: This function is deprecated and will be removed in 3.0** -Use `hilbish.runner.setCurrent` instead. -This is the same as the `hilbish.runnerMode` function. -It takes a callback, which will be used to execute all interactive input. -Or a string which names the runner mode to use. -#### Parameters -`mode` **`string|function`** - - -
- -
-
-

-hilbish.runner.sh() - - - -

- - -#### Parameters -This function has no parameters. -
- diff --git a/docs/api/hilbish/hilbish.timers.md b/docs/api/hilbish/hilbish.timers.md deleted file mode 100644 index f218d2bc..00000000 --- a/docs/api/hilbish/hilbish.timers.md +++ /dev/null @@ -1,100 +0,0 @@ ---- -title: Module hilbish.timers -description: timeout and interval API -layout: doc -menu: - docs: - parent: "API" ---- - -## Introduction - -If you ever want to run a piece of code on a timed interval, or want to wait -a few seconds, you don't have to rely on timing tricks, as Hilbish has a -timer API to set intervals and timeouts. - -These are the simple functions `hilbish.interval` and `hilbish.timeout` (doc -accessible with `doc hilbish`, or `Module hilbish` on the Website). - -An example of usage: -```lua -local t = hilbish.timers.create(hilbish.timers.TIMEOUT, 5000, function() - print 'hello!' -end) - -t:start() -print(t.running) // true -``` - -## Functions -||| -|----|----| -|create(type, time, callback) -> @Timer|Creates a timer that runs based on the specified `time`.| -|get(id) -> @Timer|Retrieves a timer via its ID.| - -## Static module fields -||| -|----|----| -|INTERVAL|Constant for an interval timer type| -|TIMEOUT|Constant for a timeout timer type| - -
-
-

-hilbish.timers.create(type, time, callback) -> Timer - - - -

- -Creates a timer that runs based on the specified `time`. - -#### Parameters -`number` **`type`** -What kind of timer to create, can either be `hilbish.timers.INTERVAL` or `hilbish.timers.TIMEOUT` - -`number` **`time`** -The amount of time the function should run in milliseconds. - -`function` **`callback`** -The function to run for the timer. - -
- -
-
-

-hilbish.timers.get(id) -> Timer - - - -

- -Retrieves a timer via its ID. - -#### Parameters -`number` **`id`** - - -
- -## Types -
- -## Timer -The Job type describes a Hilbish timer. -## Object properties -||| -|----|----| -|type|What type of timer it is| -|running|If the timer is running| -|duration|The duration in milliseconds that the timer will run| - - -### Methods -#### start() -Starts a timer. - -#### stop() -Stops a timer. - diff --git a/docs/api/readline.md b/docs/api/readline.md new file mode 100644 index 00000000..656896e0 --- /dev/null +++ b/docs/api/readline.md @@ -0,0 +1,38 @@ +--- +title: Module readline +description: Package readline is a pure-Go re-imagining of the UNIX readline API +layout: doc +menu: + docs: + parent: "API" +--- + +## Introduction + +This package is designed to be run independently from murex and at some +point it will be separated into it's own git repository (at a stage when I +am confident that murex will no longer be the primary driver for features, +bugs or other code changes) + +Package terminal provides support functions for dealing with terminals, as +commonly found on UNIX systems. + +Putting a terminal into raw mode is the most common requirement: + + oldState, err := terminal.MakeRaw(0) + if err != nil { + panic(err) + } + defer terminal.Restore(0, oldState) + +Package terminal provides support functions for dealing with terminals, as +commonly found on UNIX systems. + +Putting a terminal into raw mode is the most common requirement: + + oldState, err := terminal.MakeRaw(0) + if err != nil { + panic(err) + } + defer terminal.Restore(0, oldState) + diff --git a/emmyLuaDocs/readline.lua b/emmyLuaDocs/readline.lua new file mode 100644 index 00000000..d5294fa9 --- /dev/null +++ b/emmyLuaDocs/readline.lua @@ -0,0 +1,5 @@ +--- @meta + +local readline = {} + +return readline diff --git a/readline/CHANGES.md b/golibs/readline/CHANGES.md similarity index 100% rename from readline/CHANGES.md rename to golibs/readline/CHANGES.md diff --git a/readline/LICENSE b/golibs/readline/LICENSE similarity index 100% rename from readline/LICENSE rename to golibs/readline/LICENSE diff --git a/readline/README.md b/golibs/readline/README.md similarity index 100% rename from readline/README.md rename to golibs/readline/README.md diff --git a/readline/codes.go b/golibs/readline/codes.go similarity index 100% rename from readline/codes.go rename to golibs/readline/codes.go diff --git a/readline/comp-grid.go b/golibs/readline/comp-grid.go similarity index 100% rename from readline/comp-grid.go rename to golibs/readline/comp-grid.go diff --git a/readline/comp-group.go b/golibs/readline/comp-group.go similarity index 100% rename from readline/comp-group.go rename to golibs/readline/comp-group.go diff --git a/readline/comp-list.go b/golibs/readline/comp-list.go similarity index 100% rename from readline/comp-list.go rename to golibs/readline/comp-list.go diff --git a/readline/comp-map.go b/golibs/readline/comp-map.go similarity index 100% rename from readline/comp-map.go rename to golibs/readline/comp-map.go diff --git a/readline/cursor.go b/golibs/readline/cursor.go similarity index 100% rename from readline/cursor.go rename to golibs/readline/cursor.go diff --git a/readline/editor.go b/golibs/readline/editor.go similarity index 100% rename from readline/editor.go rename to golibs/readline/editor.go diff --git a/readline/editor_plan9.go b/golibs/readline/editor_plan9.go similarity index 100% rename from readline/editor_plan9.go rename to golibs/readline/editor_plan9.go diff --git a/readline/editor_unix.go b/golibs/readline/editor_unix.go similarity index 100% rename from readline/editor_unix.go rename to golibs/readline/editor_unix.go diff --git a/readline/editor_windows.go b/golibs/readline/editor_windows.go similarity index 100% rename from readline/editor_windows.go rename to golibs/readline/editor_windows.go diff --git a/readline/errors.go b/golibs/readline/errors.go similarity index 100% rename from readline/errors.go rename to golibs/readline/errors.go diff --git a/readline/events.go b/golibs/readline/events.go similarity index 100% rename from readline/events.go rename to golibs/readline/events.go diff --git a/readline/go.mod b/golibs/readline/go.mod similarity index 100% rename from readline/go.mod rename to golibs/readline/go.mod diff --git a/readline/go.sum b/golibs/readline/go.sum similarity index 100% rename from readline/go.sum rename to golibs/readline/go.sum diff --git a/readline/godoc.go b/golibs/readline/godoc.go similarity index 100% rename from readline/godoc.go rename to golibs/readline/godoc.go diff --git a/readline/hint.go b/golibs/readline/hint.go similarity index 100% rename from readline/hint.go rename to golibs/readline/hint.go diff --git a/readline/history.go b/golibs/readline/history.go similarity index 100% rename from readline/history.go rename to golibs/readline/history.go diff --git a/readline/info.go b/golibs/readline/info.go similarity index 100% rename from readline/info.go rename to golibs/readline/info.go diff --git a/readline/instance.go b/golibs/readline/instance.go similarity index 100% rename from readline/instance.go rename to golibs/readline/instance.go diff --git a/readline/line.go b/golibs/readline/line.go similarity index 100% rename from readline/line.go rename to golibs/readline/line.go diff --git a/readline/line_test.go b/golibs/readline/line_test.go similarity index 100% rename from readline/line_test.go rename to golibs/readline/line_test.go diff --git a/readline/prompt.go b/golibs/readline/prompt.go similarity index 100% rename from readline/prompt.go rename to golibs/readline/prompt.go diff --git a/readline/raw_bsd.go b/golibs/readline/raw_bsd.go similarity index 100% rename from readline/raw_bsd.go rename to golibs/readline/raw_bsd.go diff --git a/readline/raw_linux.go b/golibs/readline/raw_linux.go similarity index 100% rename from readline/raw_linux.go rename to golibs/readline/raw_linux.go diff --git a/readline/raw_plan9.go b/golibs/readline/raw_plan9.go similarity index 100% rename from readline/raw_plan9.go rename to golibs/readline/raw_plan9.go diff --git a/readline/raw_solaris.go b/golibs/readline/raw_solaris.go similarity index 100% rename from readline/raw_solaris.go rename to golibs/readline/raw_solaris.go diff --git a/readline/raw_unix.go b/golibs/readline/raw_unix.go similarity index 100% rename from readline/raw_unix.go rename to golibs/readline/raw_unix.go diff --git a/readline/raw_windows.go b/golibs/readline/raw_windows.go similarity index 100% rename from readline/raw_windows.go rename to golibs/readline/raw_windows.go diff --git a/readline/readline.go b/golibs/readline/readline.go similarity index 100% rename from readline/readline.go rename to golibs/readline/readline.go diff --git a/readline/register.go b/golibs/readline/register.go similarity index 100% rename from readline/register.go rename to golibs/readline/register.go diff --git a/readline/syntax.go b/golibs/readline/syntax.go similarity index 100% rename from readline/syntax.go rename to golibs/readline/syntax.go diff --git a/readline/tab-virtual.go b/golibs/readline/tab-virtual.go similarity index 100% rename from readline/tab-virtual.go rename to golibs/readline/tab-virtual.go diff --git a/readline/tab.go b/golibs/readline/tab.go similarity index 100% rename from readline/tab.go rename to golibs/readline/tab.go diff --git a/readline/tabfind.go b/golibs/readline/tabfind.go similarity index 100% rename from readline/tabfind.go rename to golibs/readline/tabfind.go diff --git a/readline/term.go b/golibs/readline/term.go similarity index 100% rename from readline/term.go rename to golibs/readline/term.go diff --git a/readline/timer.go b/golibs/readline/timer.go similarity index 100% rename from readline/timer.go rename to golibs/readline/timer.go diff --git a/readline/tokenise.go b/golibs/readline/tokenise.go similarity index 100% rename from readline/tokenise.go rename to golibs/readline/tokenise.go diff --git a/readline/tui-effects.go b/golibs/readline/tui-effects.go similarity index 100% rename from readline/tui-effects.go rename to golibs/readline/tui-effects.go diff --git a/readline/undo.go b/golibs/readline/undo.go similarity index 100% rename from readline/undo.go rename to golibs/readline/undo.go diff --git a/readline/update.go b/golibs/readline/update.go similarity index 100% rename from readline/update.go rename to golibs/readline/update.go diff --git a/readline/vim.go b/golibs/readline/vim.go similarity index 100% rename from readline/vim.go rename to golibs/readline/vim.go diff --git a/readline/vimdelete.go b/golibs/readline/vimdelete.go similarity index 100% rename from readline/vimdelete.go rename to golibs/readline/vimdelete.go diff --git a/readline/wrap.go b/golibs/readline/wrap.go similarity index 100% rename from readline/wrap.go rename to golibs/readline/wrap.go diff --git a/readline/raw/LICENSE b/readline/raw/LICENSE deleted file mode 100644 index 261eeb9e..00000000 --- a/readline/raw/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/readline/raw/README.md b/readline/raw/README.md deleted file mode 100644 index 2ef9aadb..00000000 --- a/readline/raw/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# raw - -This command exists here purely as a lazy feature for me to scan key presses -for their corresponding escape codes. It is a useful dev tool for rationalizing -what is happening in the different terminal emulators (since documentation -regarding what escape codes they send can often be non-existent and some of the -more exotic key combinations or modern keyboard functions can have multiple -published standards. - -This package is not imported by `readline` and is not required as part of `readline` \ No newline at end of file diff --git a/readline/raw/main.go b/readline/raw/main.go deleted file mode 100644 index eff84406..00000000 --- a/readline/raw/main.go +++ /dev/null @@ -1,22 +0,0 @@ -package main - -import ( - "fmt" - "os" - - "github.com/maxlandon/readline" -) - -func main() { - readline.MakeRaw(int(os.Stdin.Fd())) - - for { - b := make([]byte, 1024) - i, err := os.Stdin.Read(b) - if err != nil { - panic(err) - } - - fmt.Println(b[:i]) - } -}