Fix various small details and update readme

This commit is contained in:
Zachary Yedidia 2016-08-28 16:28:28 -04:00
parent 8cef0abf6a
commit 59b7555f01
8 changed files with 42 additions and 30 deletions

View file

@ -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.

View file

@ -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

View file

@ -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)
}

View file

@ -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

View file

@ -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 := ""

View file

@ -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
}

View file

@ -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)
}
}

View file

@ -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
}
}