From 59b7555f014440ea95885978b22cac4ed7d0629e Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Sun, 28 Aug 2016 16:28:28 -0400 Subject: [PATCH] Fix various small details and update readme --- README.md | 23 +++++++++++++++-------- cmd/micro/colorscheme.go | 3 ++- cmd/micro/command.go | 28 ++++++++++++++-------------- cmd/micro/micro.go | 6 +++++- cmd/micro/tab.go | 2 +- cmd/micro/util.go | 6 +++--- cmd/micro/util_test.go | 2 +- cmd/micro/view.go | 2 +- 8 files changed, 42 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 66139bc2..430bfa27 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,22 @@ # ![Micro](./assets/logo.png) [![Build Status](https://travis-ci.org/zyedidia/micro.svg?branch=master)](https://travis-ci.org/zyedidia/micro) -![Go Report Card](https://goreportcard.com/badge/github.com/zyedidia/micro) +[![Go Report Card](https://goreportcard.com/badge/github.com/zyedidia/micro)](https://goreportcard.com/report/github.com/zyedidia/micro) [![Join the chat at https://gitter.im/zyedidia/micro](https://badges.gitter.im/zyedidia/micro.svg)](https://gitter.im/zyedidia/micro?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/zyedidia/micro/blob/master/LICENSE) -> Micro is still a work in progress - Micro is a terminal-based text editor that aims to be easy to use and intuitive, while also taking advantage of the full capabilities of modern terminals. It comes as one single, batteries-included, static binary with no dependencies, and you can download and use it right now. +As the name indicates, micro aims to be somewhat of a successor to the nano editor by being easy to install and use in a pinch, but micro also aims to be +enjoyable to use full time, whether you work in the terminal because you prefer it (like me), or because you need to (over ssh). + Here is a picture of micro editing its source code. ![Screenshot](./assets/micro-solarized.png) +To see more screenshots of micro, showcasing all of the default colorschemes, see [here](http://zbyedidia.webfactional.com/micro/colorschemes). + # Features * Easy to use and to install @@ -37,22 +40,23 @@ Here is a picture of micro editing its source code. * Easily configurable * Common editor things such as undo/redo, line numbers, unicode support... +Although not yet implemented, I hope to add more features such as autocompletion, and multiple cursors in the future. + # Installation To install micro, you can download a prebuilt binary, or you can build it from source. -You can also install micro with a few package managers (on OSX, Arch Linux, and CRUX). -See this [wiki page](https://github.com/zyedidia/micro/wiki/Installing-Micro) for details. - Please note that micro uses the amazing [tcell library](https://github.com/gdamore/tcell), but this means that micro is restricted to the platforms tcell supports. As a result, micro does not support Plan9, NaCl, and Cygwin (although this may change in the future). +If you want more information about ways to install micro, see this [wiki page](https://github.com/zyedidia/micro/wiki/Installing-Micro) + ### Prebuilt binaries All you need to install micro is one file, the binary itself. It's as simple as that! -You can download the correct binary for your operating system from the list in the [nightly build release](https://github.com/zyedidia/micro/releases). +You can download the correct binary for your operating system from the [releases](https://github.com/zyedidia/micro/releases). On that page you'll see the nightly release, which contains binaries for micro which are built every night, and you'll see all the stable releases with the corresponding binaries. @@ -63,7 +67,7 @@ If you'd like to see more information after installing micro, run `micro -versio If your operating system does not have binary, but does run Go, you can build from source. -Make sure that you have Go version 1.5 or greater (Go 1.4 will work for the systems like support CGO then). +Make sure that you have Go version 1.5 or greater (Go 1.4 will work if your version supports CGO). ```sh go get -u github.com/zyedidia/micro/... @@ -102,6 +106,9 @@ click to enable line selection. Micro has a built-in help system which you can access by pressing `CtrlE` and typing `help`. Additionally, you can view the help files online [here](https://github.com/zyedidia/micro/tree/master/runtime/help). +I also recommend reading the [tutorial](https://github.com/zyedidia/micro/tree/master/runtime/help/tutorial.md) for +a brief introduction to the more powerful features micro offers. + # Contributing If you find any bugs, please report them! I am also happy to accept pull requests from anyone. diff --git a/cmd/micro/colorscheme.go b/cmd/micro/colorscheme.go index 13d96856..0c915b92 100644 --- a/cmd/micro/colorscheme.go +++ b/cmd/micro/colorscheme.go @@ -2,11 +2,12 @@ package main import ( "fmt" - "github.com/zyedidia/tcell" "io/ioutil" "regexp" "strconv" "strings" + + "github.com/zyedidia/tcell" ) // Colorscheme is a map from string to style -- it represents a colorscheme diff --git a/cmd/micro/command.go b/cmd/micro/command.go index 9caadf72..0c5278c7 100644 --- a/cmd/micro/command.go +++ b/cmd/micro/command.go @@ -68,17 +68,17 @@ func MakeCommand(name, function string, completions ...Completion) { // DefaultCommands returns a map containing micro's default commands func DefaultCommands() map[string]StrCommand { return map[string]StrCommand{ - "set": StrCommand{"Set", []Completion{OptionCompletion, NoCompletion}}, - "setlocal": StrCommand{"SetLocal", []Completion{OptionCompletion, NoCompletion}}, - "bind": StrCommand{"Bind", []Completion{NoCompletion}}, - "run": StrCommand{"Run", []Completion{NoCompletion}}, - "quit": StrCommand{"Quit", []Completion{NoCompletion}}, - "save": StrCommand{"Save", []Completion{NoCompletion}}, - "replace": StrCommand{"Replace", []Completion{NoCompletion}}, - "vsplit": StrCommand{"VSplit", []Completion{FileCompletion, NoCompletion}}, - "hsplit": StrCommand{"HSplit", []Completion{FileCompletion, NoCompletion}}, - "tab": StrCommand{"Tab", []Completion{FileCompletion, NoCompletion}}, - "help": StrCommand{"Help", []Completion{HelpCompletion, NoCompletion}}, + "set": {"Set", []Completion{OptionCompletion, NoCompletion}}, + "setlocal": {"SetLocal", []Completion{OptionCompletion, NoCompletion}}, + "bind": {"Bind", []Completion{NoCompletion}}, + "run": {"Run", []Completion{NoCompletion}}, + "quit": {"Quit", []Completion{NoCompletion}}, + "save": {"Save", []Completion{NoCompletion}}, + "replace": {"Replace", []Completion{NoCompletion}}, + "vsplit": {"VSplit", []Completion{FileCompletion, NoCompletion}}, + "hsplit": {"HSplit", []Completion{FileCompletion, NoCompletion}}, + "tab": {"Tab", []Completion{FileCompletion, NoCompletion}}, + "help": {"Help", []Completion{HelpCompletion, NoCompletion}}, } } @@ -308,9 +308,9 @@ func Replace(args []string) { view.Cursor.Relocate() if found > 1 { - messenger.Message("Replaced ", found, " occurences of ", search) + messenger.Message("Replaced ", found, " occurrences of ", search) } else if found == 1 { - messenger.Message("Replaced ", found, " occurence of ", search) + messenger.Message("Replaced ", found, " occurrence of ", search) } else { messenger.Message("Nothing matched ", search) } @@ -396,7 +396,7 @@ func HandleCommand(input string) { args := strings.Split(input, " ")[1:] if _, ok := commands[inputCmd]; !ok { - messenger.Error("Unkown command ", inputCmd) + messenger.Error("Unknown command ", inputCmd) } else { commands[inputCmd].action(args) } diff --git a/cmd/micro/micro.go b/cmd/micro/micro.go index ca6ab8c7..1a1fbda3 100644 --- a/cmd/micro/micro.go +++ b/cmd/micro/micro.go @@ -42,7 +42,7 @@ var ( configDir string // Version is the version number or commit hash - // This should be set by the linker when compiling + // These variables should be set by the linker when compiling Version = "Unknown" CommitHash = "Unknown" CompileDate = "Unknown" @@ -104,6 +104,10 @@ func LoadInput() []*Buffer { // The input is not a terminal, so something is being piped in // and we should read from stdin input, err = ioutil.ReadAll(os.Stdin) + if err != nil { + TermMessage("Error reading from stdin: ", err) + input = []byte{} + } buffers = append(buffers, NewBuffer(input, filename)) } else { // Option 3, just open an empty buffer diff --git a/cmd/micro/tab.go b/cmd/micro/tab.go index 9109eb9f..e907ac0e 100644 --- a/cmd/micro/tab.go +++ b/cmd/micro/tab.go @@ -61,7 +61,7 @@ func CurView() *View { // TabbarString returns the string that should be displayed in the tabbar // It also returns a map containing which indicies correspond to which tab number -// This is useful when we know that the mouse click has occured at an x location +// This is useful when we know that the mouse click has occurred at an x location // but need to know which tab that corresponds to to accurately change the tab func TabbarString() (string, map[int]int) { str := "" diff --git a/cmd/micro/util.go b/cmd/micro/util.go index 4dc2fdde..9bb019d1 100644 --- a/cmd/micro/util.go +++ b/cmd/micro/util.go @@ -20,8 +20,8 @@ func Count(s string) int { return utf8.RuneCountInString(s) } -// NumOccurences counts the number of occurences of a byte in a string -func NumOccurences(s string, c byte) int { +// NumOccurrences counts the number of occurences of a byte in a string +func NumOccurrences(s string, c byte) int { var n int for i := 0; i < len(s); i++ { if s[i] == c { @@ -154,7 +154,7 @@ func GetModTime(path string) (time.Time, bool) { // StringWidth returns the width of a string where tabs count as `tabsize` width func StringWidth(str string, tabsize int) int { sw := runewidth.StringWidth(str) - sw += NumOccurences(str, '\t') * (tabsize - 1) + sw += NumOccurrences(str, '\t') * (tabsize - 1) return sw } diff --git a/cmd/micro/util_test.go b/cmd/micro/util_test.go index 29fc009f..e37a3237 100644 --- a/cmd/micro/util_test.go +++ b/cmd/micro/util_test.go @@ -13,7 +13,7 @@ func TestNumOccurences(t *testing.T) { {"∆ƒ\tø ® \t\t", '\t', 3}, } for _, test := range tests { - if got := NumOccurences(test.inputStr, test.inputChar); got != test.want { + if got := NumOccurrences(test.inputStr, test.inputChar); got != test.want { t.Errorf("NumOccurences(%s, %c) = %d", test.inputStr, test.inputChar, got) } } diff --git a/cmd/micro/view.go b/cmd/micro/view.go index 365f05dc..b6743db8 100644 --- a/cmd/micro/view.go +++ b/cmd/micro/view.go @@ -600,7 +600,7 @@ func (v *View) DisplayView() { lineNumStyle = style } if style, ok := colorscheme["current-line-number"]; ok { - if curLineN == v.Cursor.Y { + if curLineN == v.Cursor.Y && tabs[curTab].curView == v.Num && !v.Cursor.HasSelection() { lineNumStyle = style } }