mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-16 05:47:06 +09:00
Fix various small details and update readme
This commit is contained in:
23
README.md
23
README.md
@@ -1,19 +1,22 @@
|
|||||||
# 
|
# 
|
||||||
|
|
||||||
[](https://travis-ci.org/zyedidia/micro)
|
[](https://travis-ci.org/zyedidia/micro)
|
||||||

|
[](https://goreportcard.com/report/github.com/zyedidia/micro)
|
||||||
[](https://gitter.im/zyedidia/micro?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
[](https://gitter.im/zyedidia/micro?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||||
[](https://github.com/zyedidia/micro/blob/master/LICENSE)
|
[](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
|
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.
|
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.
|
Here is a picture of micro editing its source code.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
To see more screenshots of micro, showcasing all of the default colorschemes, see [here](http://zbyedidia.webfactional.com/micro/colorschemes).
|
||||||
|
|
||||||
# Features
|
# Features
|
||||||
|
|
||||||
* Easy to use and to install
|
* Easy to use and to install
|
||||||
@@ -37,22 +40,23 @@ Here is a picture of micro editing its source code.
|
|||||||
* Easily configurable
|
* Easily configurable
|
||||||
* Common editor things such as undo/redo, line numbers, unicode support...
|
* 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
|
# Installation
|
||||||
|
|
||||||
To install micro, you can download a prebuilt binary, or you can build it from source.
|
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
|
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
|
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).
|
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
|
### Prebuilt binaries
|
||||||
|
|
||||||
All you need to install micro is one file, the binary itself. It's as simple as that!
|
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,
|
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.
|
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.
|
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
|
```sh
|
||||||
go get -u github.com/zyedidia/micro/...
|
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
|
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).
|
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
|
# Contributing
|
||||||
|
|
||||||
If you find any bugs, please report them! I am also happy to accept pull requests from anyone.
|
If you find any bugs, please report them! I am also happy to accept pull requests from anyone.
|
||||||
|
|||||||
@@ -2,11 +2,12 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/zyedidia/tcell"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/zyedidia/tcell"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Colorscheme is a map from string to style -- it represents a colorscheme
|
// Colorscheme is a map from string to style -- it represents a colorscheme
|
||||||
|
|||||||
@@ -68,17 +68,17 @@ func MakeCommand(name, function string, completions ...Completion) {
|
|||||||
// DefaultCommands returns a map containing micro's default commands
|
// DefaultCommands returns a map containing micro's default commands
|
||||||
func DefaultCommands() map[string]StrCommand {
|
func DefaultCommands() map[string]StrCommand {
|
||||||
return map[string]StrCommand{
|
return map[string]StrCommand{
|
||||||
"set": StrCommand{"Set", []Completion{OptionCompletion, NoCompletion}},
|
"set": {"Set", []Completion{OptionCompletion, NoCompletion}},
|
||||||
"setlocal": StrCommand{"SetLocal", []Completion{OptionCompletion, NoCompletion}},
|
"setlocal": {"SetLocal", []Completion{OptionCompletion, NoCompletion}},
|
||||||
"bind": StrCommand{"Bind", []Completion{NoCompletion}},
|
"bind": {"Bind", []Completion{NoCompletion}},
|
||||||
"run": StrCommand{"Run", []Completion{NoCompletion}},
|
"run": {"Run", []Completion{NoCompletion}},
|
||||||
"quit": StrCommand{"Quit", []Completion{NoCompletion}},
|
"quit": {"Quit", []Completion{NoCompletion}},
|
||||||
"save": StrCommand{"Save", []Completion{NoCompletion}},
|
"save": {"Save", []Completion{NoCompletion}},
|
||||||
"replace": StrCommand{"Replace", []Completion{NoCompletion}},
|
"replace": {"Replace", []Completion{NoCompletion}},
|
||||||
"vsplit": StrCommand{"VSplit", []Completion{FileCompletion, NoCompletion}},
|
"vsplit": {"VSplit", []Completion{FileCompletion, NoCompletion}},
|
||||||
"hsplit": StrCommand{"HSplit", []Completion{FileCompletion, NoCompletion}},
|
"hsplit": {"HSplit", []Completion{FileCompletion, NoCompletion}},
|
||||||
"tab": StrCommand{"Tab", []Completion{FileCompletion, NoCompletion}},
|
"tab": {"Tab", []Completion{FileCompletion, NoCompletion}},
|
||||||
"help": StrCommand{"Help", []Completion{HelpCompletion, NoCompletion}},
|
"help": {"Help", []Completion{HelpCompletion, NoCompletion}},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,9 +308,9 @@ func Replace(args []string) {
|
|||||||
view.Cursor.Relocate()
|
view.Cursor.Relocate()
|
||||||
|
|
||||||
if found > 1 {
|
if found > 1 {
|
||||||
messenger.Message("Replaced ", found, " occurences of ", search)
|
messenger.Message("Replaced ", found, " occurrences of ", search)
|
||||||
} else if found == 1 {
|
} else if found == 1 {
|
||||||
messenger.Message("Replaced ", found, " occurence of ", search)
|
messenger.Message("Replaced ", found, " occurrence of ", search)
|
||||||
} else {
|
} else {
|
||||||
messenger.Message("Nothing matched ", search)
|
messenger.Message("Nothing matched ", search)
|
||||||
}
|
}
|
||||||
@@ -396,7 +396,7 @@ func HandleCommand(input string) {
|
|||||||
args := strings.Split(input, " ")[1:]
|
args := strings.Split(input, " ")[1:]
|
||||||
|
|
||||||
if _, ok := commands[inputCmd]; !ok {
|
if _, ok := commands[inputCmd]; !ok {
|
||||||
messenger.Error("Unkown command ", inputCmd)
|
messenger.Error("Unknown command ", inputCmd)
|
||||||
} else {
|
} else {
|
||||||
commands[inputCmd].action(args)
|
commands[inputCmd].action(args)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ var (
|
|||||||
configDir string
|
configDir string
|
||||||
|
|
||||||
// Version is the version number or commit hash
|
// 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"
|
Version = "Unknown"
|
||||||
CommitHash = "Unknown"
|
CommitHash = "Unknown"
|
||||||
CompileDate = "Unknown"
|
CompileDate = "Unknown"
|
||||||
@@ -104,6 +104,10 @@ func LoadInput() []*Buffer {
|
|||||||
// The input is not a terminal, so something is being piped in
|
// The input is not a terminal, so something is being piped in
|
||||||
// and we should read from stdin
|
// and we should read from stdin
|
||||||
input, err = ioutil.ReadAll(os.Stdin)
|
input, err = ioutil.ReadAll(os.Stdin)
|
||||||
|
if err != nil {
|
||||||
|
TermMessage("Error reading from stdin: ", err)
|
||||||
|
input = []byte{}
|
||||||
|
}
|
||||||
buffers = append(buffers, NewBuffer(input, filename))
|
buffers = append(buffers, NewBuffer(input, filename))
|
||||||
} else {
|
} else {
|
||||||
// Option 3, just open an empty buffer
|
// Option 3, just open an empty buffer
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ func CurView() *View {
|
|||||||
|
|
||||||
// TabbarString returns the string that should be displayed in the tabbar
|
// TabbarString returns the string that should be displayed in the tabbar
|
||||||
// It also returns a map containing which indicies correspond to which tab number
|
// 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
|
// but need to know which tab that corresponds to to accurately change the tab
|
||||||
func TabbarString() (string, map[int]int) {
|
func TabbarString() (string, map[int]int) {
|
||||||
str := ""
|
str := ""
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ func Count(s string) int {
|
|||||||
return utf8.RuneCountInString(s)
|
return utf8.RuneCountInString(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NumOccurences counts the number of occurences of a byte in a string
|
// NumOccurrences counts the number of occurences of a byte in a string
|
||||||
func NumOccurences(s string, c byte) int {
|
func NumOccurrences(s string, c byte) int {
|
||||||
var n int
|
var n int
|
||||||
for i := 0; i < len(s); i++ {
|
for i := 0; i < len(s); i++ {
|
||||||
if s[i] == c {
|
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
|
// StringWidth returns the width of a string where tabs count as `tabsize` width
|
||||||
func StringWidth(str string, tabsize int) int {
|
func StringWidth(str string, tabsize int) int {
|
||||||
sw := runewidth.StringWidth(str)
|
sw := runewidth.StringWidth(str)
|
||||||
sw += NumOccurences(str, '\t') * (tabsize - 1)
|
sw += NumOccurrences(str, '\t') * (tabsize - 1)
|
||||||
return sw
|
return sw
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ func TestNumOccurences(t *testing.T) {
|
|||||||
{"∆ƒ\tø ® \t\t", '\t', 3},
|
{"∆ƒ\tø ® \t\t", '\t', 3},
|
||||||
}
|
}
|
||||||
for _, test := range tests {
|
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)
|
t.Errorf("NumOccurences(%s, %c) = %d", test.inputStr, test.inputChar, got)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -600,7 +600,7 @@ func (v *View) DisplayView() {
|
|||||||
lineNumStyle = style
|
lineNumStyle = style
|
||||||
}
|
}
|
||||||
if style, ok := colorscheme["current-line-number"]; ok {
|
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
|
lineNumStyle = style
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user