mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-26 10:27:04 +09:00
Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
19c7860f14 | ||
|
|
f6c7c488f5 | ||
|
|
bc6c9772cd | ||
|
|
fccec47ae5 | ||
|
|
eda08a994a | ||
|
|
f8071af717 | ||
|
|
6ce8fe3ce1 | ||
|
|
00e385b871 | ||
|
|
da98a2e9ec | ||
|
|
59b7555f01 | ||
|
|
8cef0abf6a | ||
|
|
56224c9184 | ||
|
|
40523871fa | ||
|
|
90e0a2ec1a | ||
|
|
aa9dbdde3e | ||
|
|
da7bc997ff | ||
|
|
0a3e2b3ff0 | ||
|
|
1260dcc5ee | ||
|
|
2de42bcf99 | ||
|
|
e0074c881c | ||
|
|
1a5e90c8a2 | ||
|
|
ff31da0d6d |
26
Makefile
26
Makefile
@@ -1,19 +1,39 @@
|
||||
.PHONY: runtime
|
||||
|
||||
VERSION = "$(shell git rev-parse --short HEAD)"
|
||||
VERSION = $(shell git describe --tags --abbrev=0)
|
||||
HASH = $(shell git rev-parse --short HEAD)
|
||||
|
||||
build: tcell
|
||||
go build -ldflags "-X main.Version=$(VERSION)" -o micro ./cmd/micro
|
||||
# Builds micro after checking dependencies but without updating the runtime
|
||||
build: deps tcell
|
||||
go build -ldflags "-X main.Version=$(VERSION) -X main.CommitHash=$(HASH) -X 'main.CompileDate=$(shell date -u '+%B %d, %Y')'" -o micro ./cmd/micro
|
||||
|
||||
# Builds micro after building the runtiem and checking dependencies
|
||||
build-all: runtime build
|
||||
|
||||
# Builds micro without checking for dependencies
|
||||
build-quick:
|
||||
go build -ldflags "-X main.Version=$(VERSION) -X main.CommitHash=$(HASH) -X 'main.CompileDate=$(shell date -u '+%B %d, %Y')'" -o micro ./cmd/micro
|
||||
|
||||
# Same as 'build' but installs to $GOPATH/bin afterward
|
||||
install: build
|
||||
mv micro $(GOPATH)/bin
|
||||
|
||||
# Same as 'build-all' but installs to $GOPATH/bin afterward
|
||||
install-all: runtime install
|
||||
|
||||
# Same as 'build-quick' but installs to $GOPATH/bin afterward
|
||||
install-quick: build-quick
|
||||
mv micro $(GOPATH)/bin
|
||||
|
||||
# Updates tcell
|
||||
tcell:
|
||||
git -C $(GOPATH)/src/github.com/zyedidia/tcell pull
|
||||
|
||||
# Checks for dependencies
|
||||
deps:
|
||||
go get -d ./cmd/micro
|
||||
|
||||
# Builds the runtime
|
||||
runtime:
|
||||
go get -u github.com/jteeuwen/go-bindata/...
|
||||
$(GOPATH)/bin/go-bindata -nometadata -o runtime.go runtime/...
|
||||
|
||||
53
README.md
53
README.md
@@ -1,19 +1,22 @@
|
||||
# 
|
||||
|
||||
[](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://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.
|
||||
|
||||

|
||||
|
||||
To see more screenshots of micro, showcasing all of the default colorschemes, see [here](http://zbyedidia.webfactional.com/micro/screenshots.html).
|
||||
|
||||
# Features
|
||||
|
||||
* Easy to use and to install
|
||||
@@ -22,10 +25,13 @@ Here is a picture of micro editing its source code.
|
||||
* Keybindings can be rebound to your liking
|
||||
* Sane defaults
|
||||
* You shouldn't have to configure much out of the box (and it is extremely easy to configure)
|
||||
* Splits and tabs
|
||||
* Extremely good mouse support
|
||||
* This means mouse dragging to create a selection, double click to select by word, and triple click to select by line
|
||||
* Cross platform (It should work on all the platforms Go runs on)
|
||||
* Note that while Windows is supported, there are still some bugs that need to be worked out
|
||||
* Plugin system (plugins are written in Lua)
|
||||
* Persistent undo
|
||||
* Automatic linting and error notifications
|
||||
* Syntax highlighting (for over [75 languages](runtime/syntax)!)
|
||||
* Colorscheme support
|
||||
@@ -36,37 +42,36 @@ 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.
|
||||
To install micro, you can download a [prebuilt binary](https://github.com/zyedidia/micro/releases), 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/tag/nightly).
|
||||
Download the binary from the [releases](https://github.com/zyedidia/micro/releases) page.
|
||||
|
||||
Micro has no released version, instead these binaries are compiled every night and you can find the
|
||||
commit they were compiled with by running `micro -version`.
|
||||
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.
|
||||
|
||||
If your operating system does not have binary, but does run Go, you can build from source.
|
||||
If you'd like to see more information after installing micro, run `micro -version`.
|
||||
|
||||
### Building 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).
|
||||
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 if your version supports CGO).
|
||||
|
||||
```sh
|
||||
go get -u github.com/zyedidia/micro/...
|
||||
```
|
||||
|
||||
### Clipboard support
|
||||
### Linux clipboard support
|
||||
|
||||
On Linux, clipboard support requires 'xclip' or 'xsel' command to be installed.
|
||||
|
||||
@@ -78,6 +83,19 @@ sudo apt-get install xclip
|
||||
|
||||
If you don't have xclip or xsel, micro will use an internal clipboard for copy and paste, but it won't work with external applications.
|
||||
|
||||
### Windows colors
|
||||
|
||||
Many of the Windows terminals don't support more than 16 colors, which means
|
||||
that micro's default colorscheme won't look very good. You can either set
|
||||
the colorscheme to `simple`, or download a better terminal emulator, like
|
||||
mintty or cmder.
|
||||
|
||||
### Plan9, NaCl, Cygwin
|
||||
|
||||
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).
|
||||
|
||||
# Usage
|
||||
|
||||
Once you have built the editor, simply start it by running `micro path/to/file.txt` or simply `micro` to open an empty buffer.
|
||||
@@ -99,6 +117,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 configuration features micro offers.
|
||||
|
||||
# Contributing
|
||||
|
||||
If you find any bugs, please report them! I am also happy to accept pull requests from anyone.
|
||||
|
||||
@@ -51,10 +51,11 @@ func (v *View) Center(usePlugin bool) bool {
|
||||
}
|
||||
|
||||
v.Topline = v.Cursor.Y - v.height/2
|
||||
if v.Topline+v.height > v.Buf.NumLines {
|
||||
v.Topline = v.Buf.NumLines - v.height
|
||||
}
|
||||
if v.Topline < 0 {
|
||||
v.Topline = 0
|
||||
} else if v.Topline+v.height > v.Buf.NumLines {
|
||||
v.Topline = v.Buf.NumLines - v.height
|
||||
}
|
||||
|
||||
if usePlugin {
|
||||
@@ -988,7 +989,7 @@ func (v *View) OpenFile(usePlugin bool) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
if v.CanClose("Continue? (yes, no, save) ") {
|
||||
if v.CanClose("Continue? (y,n,s) ", 'y', 'n', 's') {
|
||||
filename, canceled := messenger.Prompt("File to open: ", "Open", FileCompletion)
|
||||
if canceled {
|
||||
return false
|
||||
@@ -1284,7 +1285,7 @@ func (v *View) Quit(usePlugin bool) bool {
|
||||
}
|
||||
|
||||
// Make sure not to quit if there are unsaved changes
|
||||
if v.CanClose("Quit anyway? (yes, no, save) ") {
|
||||
if v.CanClose("Quit anyway? (y,n,s) ", 'y', 'n', 's') {
|
||||
v.CloseBuffer()
|
||||
if len(tabs[curTab].views) > 1 {
|
||||
v.splitNode.Delete()
|
||||
|
||||
@@ -49,6 +49,10 @@ func FileComplete(input string) (string, []string) {
|
||||
} else {
|
||||
chosen = suggestions[0]
|
||||
}
|
||||
} else {
|
||||
if len(dirs) > 1 {
|
||||
chosen = strings.Join(dirs[:len(dirs)-1], "/") + "/"
|
||||
}
|
||||
}
|
||||
|
||||
return chosen, suggestions
|
||||
@@ -88,6 +92,15 @@ func HelpComplete(input string) (string, []string) {
|
||||
return chosen, suggestions
|
||||
}
|
||||
|
||||
func contains(s []string, e string) bool {
|
||||
for _, a := range s {
|
||||
if a == e {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// OptionComplete autocompletes options
|
||||
func OptionComplete(input string) (string, []string) {
|
||||
var suggestions []string
|
||||
@@ -98,7 +111,7 @@ func OptionComplete(input string) (string, []string) {
|
||||
}
|
||||
}
|
||||
for option := range localSettings {
|
||||
if strings.HasPrefix(option, input) {
|
||||
if strings.HasPrefix(option, input) && !contains(suggestions, option) {
|
||||
suggestions = append(suggestions, option)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -15,7 +16,7 @@ type Colorscheme map[string]tcell.Style
|
||||
// The current colorscheme
|
||||
var colorscheme Colorscheme
|
||||
|
||||
var preInstalledColors = []string{"default", "solarized", "solarized-tc", "atom-dark-tc", "monokai", "gruvbox"}
|
||||
var preInstalledColors = []string{"default", "simple", "solarized", "solarized-tc", "atom-dark-tc", "monokai", "gruvbox", "zenburn"}
|
||||
|
||||
// InitColorscheme picks and initializes the colorscheme when micro starts
|
||||
func InitColorscheme() {
|
||||
|
||||
@@ -27,6 +27,7 @@ var commands map[string]Command
|
||||
var commandActions = map[string]func([]string){
|
||||
"Set": Set,
|
||||
"SetLocal": SetLocal,
|
||||
"Show": Show,
|
||||
"Run": Run,
|
||||
"Bind": Bind,
|
||||
"Quit": Quit,
|
||||
@@ -68,17 +69,18 @@ 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}},
|
||||
"show": {"Show", []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}},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,6 +170,7 @@ func NewTab(args []string) {
|
||||
// Set sets an option
|
||||
func Set(args []string) {
|
||||
if len(args) < 2 {
|
||||
messenger.Error("Not enough arguments")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -177,8 +180,10 @@ func Set(args []string) {
|
||||
SetOptionAndSettings(option, value)
|
||||
}
|
||||
|
||||
// SetLocal sets an option local to the buffer
|
||||
func SetLocal(args []string) {
|
||||
if len(args) < 2 {
|
||||
messenger.Error("Not enough arguments")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -191,10 +196,27 @@ func SetLocal(args []string) {
|
||||
}
|
||||
}
|
||||
|
||||
// Show shows the value of the given option
|
||||
func Show(args []string) {
|
||||
if len(args) < 1 {
|
||||
messenger.Error("Please provide an option to show")
|
||||
return
|
||||
}
|
||||
|
||||
option := GetOption(args[0])
|
||||
|
||||
if option == nil {
|
||||
messenger.Error(args[0], " is not a valid option")
|
||||
return
|
||||
}
|
||||
|
||||
messenger.Message(option)
|
||||
}
|
||||
|
||||
// Bind creates a new keybinding
|
||||
func Bind(args []string) {
|
||||
if len(args) != 2 {
|
||||
messenger.Error("Incorrect number of arguments")
|
||||
if len(args) < 2 {
|
||||
messenger.Error("Not enough arguments")
|
||||
return
|
||||
}
|
||||
BindKey(args[0], args[1])
|
||||
@@ -308,9 +330,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 +418,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)
|
||||
}
|
||||
|
||||
@@ -482,7 +482,6 @@ func Match(v *View) SyntaxMatches {
|
||||
for _, value := range indicies {
|
||||
start := runePos(value[0], line)
|
||||
end := runePos(value[1], line)
|
||||
// messenger.Message(start, " ", end)
|
||||
for i := start; i < end; i++ {
|
||||
matches[lineN][i] = rule.style
|
||||
}
|
||||
|
||||
@@ -124,6 +124,35 @@ func (m *Messenger) YesNoPrompt(prompt string) (bool, bool) {
|
||||
}
|
||||
}
|
||||
|
||||
// LetterPrompt gives the user a prompt and waits for a one letter response
|
||||
func (m *Messenger) LetterPrompt(prompt string, responses ...rune) (rune, bool) {
|
||||
m.Message(prompt)
|
||||
|
||||
_, h := screen.Size()
|
||||
for {
|
||||
m.Clear()
|
||||
m.Display()
|
||||
screen.ShowCursor(Count(m.message), h-1)
|
||||
screen.Show()
|
||||
event := <-events
|
||||
|
||||
switch e := event.(type) {
|
||||
case *tcell.EventKey:
|
||||
switch e.Key() {
|
||||
case tcell.KeyRune:
|
||||
for _, r := range responses {
|
||||
if e.Rune() == r {
|
||||
m.Reset()
|
||||
return r, false
|
||||
}
|
||||
}
|
||||
case tcell.KeyCtrlC, tcell.KeyCtrlQ, tcell.KeyEscape:
|
||||
return ' ', true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type Completion int
|
||||
|
||||
const (
|
||||
@@ -195,6 +224,10 @@ func (m *Messenger) Prompt(prompt, historyType string, completionTypes ...Comple
|
||||
chosen, suggestions = OptionComplete(currentArg)
|
||||
}
|
||||
|
||||
if len(suggestions) > 1 {
|
||||
chosen = chosen + CommonSubstring(suggestions...)
|
||||
}
|
||||
|
||||
if chosen != "" {
|
||||
if len(args) > 1 {
|
||||
chosen = " " + chosen
|
||||
|
||||
@@ -42,8 +42,10 @@ var (
|
||||
configDir string
|
||||
|
||||
// Version is the version number or commit hash
|
||||
// This should be set by the linker when compiling
|
||||
Version = "Unknown"
|
||||
// These variables should be set by the linker when compiling
|
||||
Version = "Unknown"
|
||||
CommitHash = "Unknown"
|
||||
CompileDate = "Unknown"
|
||||
|
||||
// L is the lua state
|
||||
// This is the VM that runs the plugins
|
||||
@@ -91,7 +93,8 @@ func LoadInput() []*Buffer {
|
||||
input, err = ioutil.ReadFile(filename)
|
||||
if err != nil {
|
||||
TermMessage(err)
|
||||
continue
|
||||
input = []byte{}
|
||||
filename = ""
|
||||
}
|
||||
}
|
||||
// If the file didn't exist, input will be empty, and we'll open an empty buffer
|
||||
@@ -102,6 +105,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
|
||||
@@ -194,7 +201,9 @@ func main() {
|
||||
flag.Parse()
|
||||
if *flagVersion {
|
||||
// If -version was passed
|
||||
fmt.Println("Micro version:", Version)
|
||||
fmt.Println("Version:", Version)
|
||||
fmt.Println("Commit hash:", CommitHash)
|
||||
fmt.Println("Compiled on", CompileDate)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -150,13 +150,13 @@ func GetOption(name string) interface{} {
|
||||
return GetGlobalOption(name)
|
||||
}
|
||||
|
||||
// DefaultSettings returns the default settings for micro
|
||||
// DefaultGlobalSettings returns the default global settings for micro
|
||||
// Note that colorscheme is a global only option
|
||||
func DefaultGlobalSettings() map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
"autoindent": true,
|
||||
"colorscheme": "monokai",
|
||||
"cursorline": false,
|
||||
"colorscheme": "zenburn",
|
||||
"cursorline": true,
|
||||
"ignorecase": false,
|
||||
"indentchar": " ",
|
||||
"ruler": true,
|
||||
@@ -176,7 +176,7 @@ func DefaultGlobalSettings() map[string]interface{} {
|
||||
func DefaultLocalSettings() map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
"autoindent": true,
|
||||
"cursorline": false,
|
||||
"cursorline": true,
|
||||
"filetype": "Unknown",
|
||||
"ignorecase": false,
|
||||
"indentchar": " ",
|
||||
|
||||
@@ -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 := ""
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -182,6 +182,34 @@ func runePos(p int, str string) int {
|
||||
return utf8.RuneCountInString(str[:p])
|
||||
}
|
||||
|
||||
func lcs(a, b string) string {
|
||||
arunes := []rune(a)
|
||||
brunes := []rune(b)
|
||||
|
||||
lcs := ""
|
||||
for i, r := range arunes {
|
||||
if i >= len(brunes) {
|
||||
break
|
||||
}
|
||||
if r == brunes[i] {
|
||||
lcs += string(r)
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
return lcs
|
||||
}
|
||||
|
||||
func CommonSubstring(arr ...string) string {
|
||||
commonStr := arr[0]
|
||||
|
||||
for _, str := range arr[1:] {
|
||||
commonStr = lcs(commonStr, str)
|
||||
}
|
||||
|
||||
return commonStr
|
||||
}
|
||||
|
||||
// Abs is a simple absolute value function for ints
|
||||
func Abs(n int) int {
|
||||
if n < 0 {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,13 +169,13 @@ func (v *View) ScrollDown(n int) {
|
||||
// If there are unsaved changes, the user will be asked if the view can be closed
|
||||
// causing them to lose the unsaved changes
|
||||
// The message is what to print after saying "You have unsaved changes. "
|
||||
func (v *View) CanClose(msg string) bool {
|
||||
func (v *View) CanClose(msg string, responses ...rune) bool {
|
||||
if v.Buf.IsModified {
|
||||
quit, canceled := messenger.Prompt("You have unsaved changes. "+msg, "Unsaved", NoCompletion)
|
||||
char, canceled := messenger.LetterPrompt("You have unsaved changes. "+msg, responses...)
|
||||
if !canceled {
|
||||
if strings.ToLower(quit) == "yes" || strings.ToLower(quit) == "y" {
|
||||
if char == 'y' {
|
||||
return true
|
||||
} else if strings.ToLower(quit) == "save" || strings.ToLower(quit) == "s" {
|
||||
} else if char == 's' {
|
||||
v.Save(true)
|
||||
return true
|
||||
}
|
||||
@@ -217,7 +217,7 @@ func (v *View) CloseBuffer() {
|
||||
|
||||
// ReOpen reloads the current buffer
|
||||
func (v *View) ReOpen() {
|
||||
if v.CanClose("Continue? (yes, no, save) ") {
|
||||
if v.CanClose("Continue? (y,n,s) ", 'y', 'n', 's') {
|
||||
screen.Clear()
|
||||
v.Buf.ReOpen()
|
||||
v.Relocate()
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
color-link comment "blue"
|
||||
color-link constant "red"
|
||||
color-link identifier "cyan"
|
||||
color-link statement "yellow"
|
||||
color-link preproc "magenta"
|
||||
color-link type "green"
|
||||
color-link special "magenta"
|
||||
color-link ignore "default"
|
||||
color-link error ",brightred"
|
||||
color-link todo ",brightyellow"
|
||||
color-link indent-char "black"
|
||||
color-link line-number "yellow"
|
||||
color-link current-line-number "red"
|
||||
color-link gutter-error ",red"
|
||||
color-link gutter-warning "red"
|
||||
color-link cursor-line "white"
|
||||
color-link default "188,237"
|
||||
color-link comment "108,237"
|
||||
color-link constant.string "174,237"
|
||||
color-link constant.number "116,237"
|
||||
color-link constant "181,237"
|
||||
color-link identifier "223,237"
|
||||
color-link statement "223,237"
|
||||
color-link preproc "223,237"
|
||||
color-link type "187,237"
|
||||
color-link special "181,237"
|
||||
color-link underlined "188,237"
|
||||
color-link error "115,236"
|
||||
color-link todo "bold 254,237"
|
||||
color-link statusline "186,236"
|
||||
color-link indent-char "238,237"
|
||||
color-link line-number "188,238"
|
||||
color-link gutter-error "237,174"
|
||||
color-link gutter-warning "174,237"
|
||||
color-link cursor-line "238"
|
||||
color-link current-line-number "188,237"
|
||||
|
||||
16
runtime/colorschemes/simple.micro
Normal file
16
runtime/colorschemes/simple.micro
Normal file
@@ -0,0 +1,16 @@
|
||||
color-link comment "blue"
|
||||
color-link constant "red"
|
||||
color-link identifier "cyan"
|
||||
color-link statement "yellow"
|
||||
color-link preproc "magenta"
|
||||
color-link type "green"
|
||||
color-link special "magenta"
|
||||
color-link ignore "default"
|
||||
color-link error ",brightred"
|
||||
color-link todo ",brightyellow"
|
||||
color-link indent-char "black"
|
||||
color-link line-number "yellow"
|
||||
color-link current-line-number "red"
|
||||
color-link gutter-error ",red"
|
||||
color-link gutter-warning "red"
|
||||
color-link cursor-line "white"
|
||||
20
runtime/colorschemes/zenburn.micro
Normal file
20
runtime/colorschemes/zenburn.micro
Normal file
@@ -0,0 +1,20 @@
|
||||
color-link default "188,237"
|
||||
color-link comment "108,237"
|
||||
color-link constant.string "174,237"
|
||||
color-link constant.number "116,237"
|
||||
color-link constant "181,237"
|
||||
color-link identifier "223,237"
|
||||
color-link statement "223,237"
|
||||
color-link preproc "223,237"
|
||||
color-link type "187,237"
|
||||
color-link special "181,237"
|
||||
color-link underlined "188,237"
|
||||
color-link error "115,236"
|
||||
color-link todo "bold 254,237"
|
||||
color-link statusline "186,236"
|
||||
color-link indent-char "238,237"
|
||||
color-link line-number "248,238"
|
||||
color-link gutter-error "237,174"
|
||||
color-link gutter-warning "174,237"
|
||||
color-link cursor-line "238"
|
||||
color-link current-line-number "188,237"
|
||||
@@ -9,9 +9,13 @@ This help page aims to cover two aspects of micro's syntax highlighting engine:
|
||||
|
||||
Micro comes with a number of colorschemes by default. Here is the list:
|
||||
|
||||
* default: this is the simplest colorscheme. It uses 16 colors which are
|
||||
* simple: this is the simplest colorscheme. It uses 16 colors which are
|
||||
set by your terminal
|
||||
|
||||
* zenburn: this is micro's default colorscheme because it looks very good
|
||||
and works in 256 color terminals.
|
||||
this colorscheme also has the name 'default'
|
||||
|
||||
* solarized: this is the solarized colorscheme.
|
||||
You should have the solarized color palette in your terminal to use it.
|
||||
|
||||
@@ -19,8 +23,8 @@ Micro comes with a number of colorschemes by default. Here is the list:
|
||||
make sure your terminal supports true color before using it and that the
|
||||
MICRO_TRUECOLOR environment variable is set to 1 before starting micro.
|
||||
|
||||
* monokai: this is the monokai colorscheme and is micro's default colorscheme
|
||||
(as well as sublime text's). It requires true color to
|
||||
* monokai: this is the monokai colorscheme, you may recognize it as
|
||||
sublime text's default colorscheme. It requires true color to
|
||||
look perfect, but the 256 color approximation looks very good as well.
|
||||
|
||||
* atom-dark-tc: this colorscheme is based off of Atom's "dark" colorscheme.
|
||||
|
||||
@@ -21,6 +21,8 @@ Here are the possible commands that you can use.
|
||||
* `setlocal option value`: sets the option to value locally (only in the current
|
||||
buffer).
|
||||
|
||||
* `show option`: shows the current value of the given option.
|
||||
|
||||
* `run sh-command`: runs the given shell command in the background. The
|
||||
command's output will be displayed in one line when it finishes running.
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ Typing help followed by nothing will open this page.
|
||||
|
||||
Here are the possible help topics that you can read:
|
||||
|
||||
* tutorial: A brief tutorial which gives an overview of all the other help topics
|
||||
* keybindings: Gives a full list of the default keybindings as well as how to rebind them
|
||||
* commands: Gives a list of all the commands and what they do
|
||||
* options: Gives a list of all the options you can customize
|
||||
@@ -21,15 +22,6 @@ Here are the possible help topics that you can read:
|
||||
|
||||
For example to open the help page on plugins you would press CtrlE and type `help plugins`.
|
||||
|
||||
### Usage
|
||||
|
||||
Once you have built the editor, simply start it by running
|
||||
`micro path/to/file.txt` or simply `micro` to open an empty buffer.
|
||||
|
||||
Micro also supports creating buffers from stdin:
|
||||
|
||||
```
|
||||
$ ifconfig | micro
|
||||
```
|
||||
|
||||
You can move the cursor around with the arrow keys and mouse.
|
||||
I recommend looking at the `tutorial` help file because it is short for each section and
|
||||
gives concrete examples of how to use the various configuration options in micro. However,
|
||||
it does not give the in-depth documentation that the other topics provide.
|
||||
|
||||
@@ -136,6 +136,7 @@ InsertNewline
|
||||
InsertSpace
|
||||
Backspace
|
||||
Delete
|
||||
Center
|
||||
InsertTab
|
||||
Save
|
||||
Find
|
||||
|
||||
@@ -20,21 +20,8 @@ Here are the options that you can set:
|
||||
~/.config/micro/colorschemes/ directory. Micro comes by default with three
|
||||
colorschemes:
|
||||
|
||||
* default: this is the default colorscheme.
|
||||
|
||||
* solarized: this is the solarized colorscheme (used in the screenshot).
|
||||
You should have the solarized color palette in your terminal to use it.
|
||||
|
||||
* solarized-tc: this is the solarized colorscheme for true color, just
|
||||
make sure your terminal supports true color before using it and that the
|
||||
MICRO_TRUECOLOR environment variable is set to 1 before starting micro.
|
||||
|
||||
* monokai-tc: this is the monokai colorscheme. It requires true color to
|
||||
look perfect, but the 256 color approximation looks good as well.
|
||||
|
||||
* atom-dark-tc: this colorscheme is based off of Atom's "dark" colorscheme.
|
||||
It requires true color to look good.
|
||||
|
||||
You can read more about micro's colorschemes in the `colors` help topic
|
||||
(`help colors`).
|
||||
|
||||
* `tabsize`: sets the tab size to `option`
|
||||
|
||||
@@ -68,7 +55,7 @@ Here are the options that you can set:
|
||||
* `cursorline`: highlight the line that the cursor is on in a different color
|
||||
(the color is defined by the colorscheme you are using)
|
||||
|
||||
default value: `off`
|
||||
default value: `on`
|
||||
|
||||
* `ruler`: display line numbers
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ color statement "[.:;,+*|=!\%]" "<" ">" "/" "-" "&"
|
||||
#Parenthetical Color
|
||||
# color magenta "[(){}]" "\[" "\]"
|
||||
|
||||
color constant.number "\b[0-9]+\b"
|
||||
|
||||
##
|
||||
## String highlighting. You will in general want your brightblacks and
|
||||
|
||||
@@ -13,27 +13,27 @@ color statement "\.\.(\.)?|!|\*|&|~|\(|\)|\[|\]|\\|/|\+|-|%|<|>|\?|:|;"
|
||||
color error "(0[0-7_]*)(L[uU]?|[uU]L?)?"
|
||||
|
||||
## Decimal integer literals
|
||||
color constant "([0-9]|[1-9][0-9_]*)(L[uU]?|[uU]L?)?"
|
||||
color constant.number "([0-9]|[1-9][0-9_]*)(L[uU]?|[uU]L?)?"
|
||||
|
||||
## Binary integer literals
|
||||
color constant "(0[bB][01_]*)(L[uU]?|[uU]L?)?"
|
||||
|
||||
## Decimal float literals
|
||||
color constant "[0-9][0-9_]*\.([0-9][0-9_]*)([eE][+-]?([0-9][0-9_]*))?[fFL]?i?"
|
||||
color constant "[0-9][0-9_]*([eE][+-]?([0-9][0-9_]*))[fFL]?i?"
|
||||
color constant "[^.]\.([0-9][0-9_]*)([eE][+-]?([0-9][0-9_]*))?[fFL]?i?"
|
||||
color constant "[0-9][0-9_]*([fFL]?i|[fF])"
|
||||
color constant.number "[0-9][0-9_]*\.([0-9][0-9_]*)([eE][+-]?([0-9][0-9_]*))?[fFL]?i?"
|
||||
color constant.number "[0-9][0-9_]*([eE][+-]?([0-9][0-9_]*))[fFL]?i?"
|
||||
color constant.number "[^.]\.([0-9][0-9_]*)([eE][+-]?([0-9][0-9_]*))?[fFL]?i?"
|
||||
color constant.number "[0-9][0-9_]*([fFL]?i|[fF])"
|
||||
|
||||
## Hexadecimal integer literals
|
||||
color constant "(0[xX]([0-9a-fA-F][0-9a-fA-F_]*|[0-9a-fA-F_]*[0-9a-fA-F]))(L[uU]?|[uU]L?)?"
|
||||
color constant.number "(0[xX]([0-9a-fA-F][0-9a-fA-F_]*|[0-9a-fA-F_]*[0-9a-fA-F]))(L[uU]?|[uU]L?)?"
|
||||
|
||||
## Hexadecimal float literals
|
||||
color constant "0[xX]([0-9a-fA-F][0-9a-fA-F_]*|[0-9a-fA-F_]*[0-9a-fA-F])(\.[0-9a-fA-F][0-9a-fA-F_]*|[0-9a-fA-F_]*[0-9a-fA-F])?[pP][+-]?([0-9][0-9_]*)[fFL]?i?"
|
||||
color constant "0[xX]\.([0-9a-fA-F][0-9a-fA-F_]*|[0-9a-fA-F_]*[0-9a-fA-F])[pP][+-]?([0-9][0-9_]*)[fFL]?i?"
|
||||
color constant.number "0[xX]([0-9a-fA-F][0-9a-fA-F_]*|[0-9a-fA-F_]*[0-9a-fA-F])(\.[0-9a-fA-F][0-9a-fA-F_]*|[0-9a-fA-F_]*[0-9a-fA-F])?[pP][+-]?([0-9][0-9_]*)[fFL]?i?"
|
||||
color constant.number "0[xX]\.([0-9a-fA-F][0-9a-fA-F_]*|[0-9a-fA-F_]*[0-9a-fA-F])[pP][+-]?([0-9][0-9_]*)[fFL]?i?"
|
||||
|
||||
|
||||
## Character literals
|
||||
color constant "'([^\']|\\(['"?\abfnrtv]|x[[:xdigit:]]{2}|[0-7]{1,3}|u[[:xdigit:]]{4}|U[[:xdigit:]]{8}|&.*;))'"
|
||||
color constant.string "'([^\']|\\(['"?\abfnrtv]|x[[:xdigit:]]{2}|[0-7]{1,3}|u[[:xdigit:]]{4}|U[[:xdigit:]]{8}|&.*;))'"
|
||||
|
||||
## Keywords
|
||||
## a-e
|
||||
|
||||
@@ -6,6 +6,7 @@ color statement "\b(break|case|catch|continue|default|do|else|finally|for|if|ret
|
||||
color type "\b(abstract|class|extends|final|implements|import|instanceof|interface|native|package|private|protected|public|static|strictfp|super|synchronized|throws|volatile)\b"
|
||||
color constant.string ""[^"]*""
|
||||
color constant "\b(true|false|null)\b"
|
||||
color constant.number "\b[0-9]+\b"
|
||||
color comment "//.*"
|
||||
color comment start="/\*" end="\*/"
|
||||
color comment start="/\*\*" end="\*/"
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
syntax "javascript" "\.js$"
|
||||
|
||||
color blue "\b[-+]?([1-9][0-9]*|0[0-7]*|0x[0-9a-fA-F]+)([uU][lL]?|[lL][uU]?)?\b"
|
||||
color blue "\b[-+]?([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([EePp][+-]?[0-9]+)?[fFlL]?"
|
||||
color blue "\b[-+]?([0-9]+[EePp][+-]?[0-9]+)[fFlL]?"
|
||||
color brightblue "[A-Za-z_][A-Za-z0-9_]*[[:space:]]*[(]"
|
||||
color constant.number "\b[-+]?([1-9][0-9]*|0[0-7]*|0x[0-9a-fA-F]+)([uU][lL]?|[lL][uU]?)?\b"
|
||||
color constant.number "\b[-+]?([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([EePp][+-]?[0-9]+)?[fFlL]?"
|
||||
color constant.number "\b[-+]?([0-9]+[EePp][+-]?[0-9]+)[fFlL]?"
|
||||
color identifier "[A-Za-z_][A-Za-z0-9_]*[[:space:]]*[(]"
|
||||
color statement "\b(break|case|catch|continue|default|delete|do|else|finally)\b"
|
||||
color statement "\b(for|function|get|if|in|instanceof|new|return|set|switch)\b"
|
||||
color statement "\b(switch|this|throw|try|typeof|var|void|while|with)\b"
|
||||
|
||||
@@ -46,7 +46,7 @@ color constant "\b(false|nil|true)\b"
|
||||
color statement "(\b(dofile|require|include)|%q|%!|%Q|%r|%x)\b"
|
||||
|
||||
# Numbers
|
||||
color constant "\b([0-9]+)\b"
|
||||
color constant.number "\b([0-9]+)\b"
|
||||
|
||||
# Symbols
|
||||
color statement "(\(|\)|\[|\]|\{|\})"
|
||||
|
||||
@@ -30,7 +30,7 @@ color statement "[.:;,+*|=!\%@]" "<" ">" "/" "-" "&"
|
||||
color statement "[(){}]" "\[" "\]"
|
||||
|
||||
## numbers
|
||||
color constant "\b[0-9]+\b"
|
||||
color constant.number "\b[0-9]+\b"
|
||||
|
||||
## strings
|
||||
color constant.string ""(\\.|[^"])*"|'(\\.|[^'])*'"
|
||||
|
||||
@@ -7,6 +7,7 @@ header "^#!.*/(env +)?ruby( |$)"
|
||||
color statement "\b(BEGIN|END|alias|and|begin|break|case|class|def|defined\?|do|else|elsif|end|ensure|false|for|if|in|module|next|nil|not|or|redo|rescue|retry|return|self|super|then|true|undef|unless|until|when|while|yield)\b"
|
||||
## Constants
|
||||
color constant "(\$|@|@@)?\b[A-Z]+[0-9A-Z_a-z]*"
|
||||
color constant.number "\b[0-9]+\b"
|
||||
## Ruby "symbols"
|
||||
color constant (i) "([ ]|^):[0-9A-Z_]+\b"
|
||||
## Some unique things we want to stand out
|
||||
@@ -15,14 +16,14 @@ color constant "\b(__FILE__|__LINE__)\b"
|
||||
color constant "/([^/]|(\\/))*/[iomx]*" "%r\{([^}]|(\\}))*\}[iomx]*"
|
||||
## Shell command expansion is in `backticks` or like %x{this}. These are
|
||||
## "double-quotish" (to use a perlism).
|
||||
color constant "`[^`]*`" "%x\{[^}]*\}"
|
||||
color constant.string "`[^`]*`" "%x\{[^}]*\}"
|
||||
## Strings, double-quoted
|
||||
color constant ""([^"]|(\\"))*"" "%[QW]?\{[^}]*\}" "%[QW]?\([^)]*\)" "%[QW]?<[^>]*>" "%[QW]?\[[^]]*\]" "%[QW]?\$[^$]*\$" "%[QW]?\^[^^]*\^" "%[QW]?![^!]*!"
|
||||
color constant.string ""([^"]|(\\"))*"" "%[QW]?\{[^}]*\}" "%[QW]?\([^)]*\)" "%[QW]?<[^>]*>" "%[QW]?\[[^]]*\]" "%[QW]?\$[^$]*\$" "%[QW]?\^[^^]*\^" "%[QW]?![^!]*!"
|
||||
## Expression substitution. These go inside double-quoted strings,
|
||||
## "like #{this}".
|
||||
color special "#\{[^}]*\}"
|
||||
## Strings, single-quoted
|
||||
color constant "'([^']|(\\'))*'" "%[qw]\{[^}]*\}" "%[qw]\([^)]*\)" "%[qw]<[^>]*>" "%[qw]\[[^]]*\]" "%[qw]\$[^$]*\$" "%[qw]\^[^^]*\^" "%[qw]![^!]*!"
|
||||
color constant.string "'([^']|(\\'))*'" "%[qw]\{[^}]*\}" "%[qw]\([^)]*\)" "%[qw]<[^>]*>" "%[qw]\[[^]]*\]" "%[qw]\$[^$]*\$" "%[qw]\^[^^]*\^" "%[qw]![^!]*!"
|
||||
## Comments
|
||||
color comment "#[^{].*$" "#$"
|
||||
color comment "##[^{].*$" "##$"
|
||||
|
||||
@@ -16,6 +16,9 @@ color special "[a-z_]+!"
|
||||
# Constants
|
||||
color constant "[A-Z][A-Z_]+"
|
||||
|
||||
# Numbers
|
||||
color constant.number "\b[0-9]+\b"
|
||||
|
||||
# Traits/Enums/Structs/Types/etc.
|
||||
color type "[A-Z][a-z]+"
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ syntax "shell" "\.sh$" "\.bash" "\.bashrc" "bashrc" "\.bash_aliases" "bash_alias
|
||||
header "^#!.*/(env +)?(ba)?sh( |$)"
|
||||
|
||||
# Numbers
|
||||
color constant "\b[0-9]+\b"
|
||||
color constant.number "\b[0-9]+\b"
|
||||
|
||||
# Conditionals and control flow
|
||||
color statement "\b(case|do|done|elif|else|esac|exit|fi|for|function|if|in|local|read|return|select|shift|then|time|until|while)\b"
|
||||
|
||||
@@ -16,7 +16,7 @@ color statement "(print)"
|
||||
color statement "(init)"
|
||||
|
||||
# Numbers
|
||||
color constant "([0-9]+)"
|
||||
color constant.number "([0-9]+)"
|
||||
|
||||
# Standard Types
|
||||
color type "\ ((U)?Int(8|16|32|64))"
|
||||
|
||||
@@ -5,4 +5,5 @@ color statement "\b([nvxsoilc]?(nore|un)?map|[nvlx]n|[ico]?no|[cilovx][um]|s?un
|
||||
color statement "\b(snor|nun|nm|set|if|endif|let|unlet)\b"
|
||||
color statement "[!&=]"
|
||||
color constant.string ""(\\.|[^"])*"|'(\\.|[^'])*'"
|
||||
color constant.number "\b[0-9]+\b"
|
||||
color comment "(^|[[:space:]])\"[^"]*$"
|
||||
|
||||
@@ -6,55 +6,55 @@ mkdir -p micro-$1
|
||||
cp LICENSE micro-$1
|
||||
cp README.md micro-$1
|
||||
|
||||
VERSION="$(git rev-parse --short HEAD)"
|
||||
HASH="$(git rev-parse --short HEAD)"
|
||||
|
||||
# Mac
|
||||
echo "OSX 64"
|
||||
GOOS=darwin GOARCH=amd64 go build -ldflags "-X main.Version=$VERSION" -o micro-$1/micro ./cmd/micro
|
||||
GOOS=darwin GOARCH=amd64 go build -ldflags "-X main.Version=$1 -X main.CommitHash=$HASH -X 'main.CompileDate=$(date -u '+%B %d, %Y')'" -o micro-$1/micro ./cmd/micro
|
||||
tar -czf micro-$1-osx.tar.gz micro-$1
|
||||
mv micro-$1-osx.tar.gz binaries
|
||||
|
||||
# Linux
|
||||
echo "Linux 64"
|
||||
GOOS=linux GOARCH=amd64 go build -ldflags "-X main.Version=$VERSION" -o micro-$1/micro ./cmd/micro
|
||||
GOOS=linux GOARCH=amd64 go build -ldflags "-X main.Version=$1 -X main.CommitHash=$HASH -X 'main.CompileDate=$(date -u '+%B %d, %Y')'" -o micro-$1/micro ./cmd/micro
|
||||
tar -czf micro-$1-linux64.tar.gz micro-$1
|
||||
mv micro-$1-linux64.tar.gz binaries
|
||||
echo "Linux 32"
|
||||
GOOS=linux GOARCH=386 go build -ldflags "-X main.Version=$VERSION" -o micro-$1/micro ./cmd/micro
|
||||
GOOS=linux GOARCH=386 go build -ldflags "-X main.Version=$1 -X main.CommitHash=$HASH -X 'main.CompileDate=$(date -u '+%B %d, %Y')'" -o micro-$1/micro ./cmd/micro
|
||||
tar -czf micro-$1-linux32.tar.gz micro-$1
|
||||
mv micro-$1-linux32.tar.gz binaries
|
||||
echo "Linux arm"
|
||||
GOOS=linux GOARCH=arm go build -ldflags "-X main.Version=$VERSION" -o micro-$1/micro ./cmd/micro
|
||||
GOOS=linux GOARCH=arm go build -ldflags "-X main.Version=$1 -X main.CommitHash=$HASH -X 'main.CompileDate=$(date -u '+%B %d, %Y')'" -o micro-$1/micro ./cmd/micro
|
||||
tar -czf micro-$1-linux-arm.tar.gz micro-$1
|
||||
mv micro-$1-linux-arm.tar.gz binaries
|
||||
|
||||
# NetBSD
|
||||
echo "NetBSD 64"
|
||||
GOOS=netbsd GOARCH=amd64 go build -ldflags "-X main.Version=$VERSION" -o micro-$1/micro ./cmd/micro
|
||||
GOOS=netbsd GOARCH=amd64 go build -ldflags "-X main.Version=$1 -X main.CommitHash=$HASH -X 'main.CompileDate=$(date -u '+%B %d, %Y')'" -o micro-$1/micro ./cmd/micro
|
||||
tar -czf micro-$1-netbsd64.tar.gz micro-$1
|
||||
mv micro-$1-netbsd64.tar.gz binaries
|
||||
echo "NetBSD 32"
|
||||
GOOS=netbsd GOARCH=386 go build -ldflags "-X main.Version=$VERSION" -o micro-$1/micro ./cmd/micro
|
||||
GOOS=netbsd GOARCH=386 go build -ldflags "-X main.Version=$1 -X main.CommitHash=$HASH -X 'main.CompileDate=$(date -u '+%B %d, %Y')'" -o micro-$1/micro ./cmd/micro
|
||||
tar -czf micro-$1-netbsd32.tar.gz micro-$1
|
||||
mv micro-$1-netbsd32.tar.gz binaries
|
||||
|
||||
# OpenBSD
|
||||
echo "OpenBSD 64"
|
||||
GOOS=openbsd GOARCH=amd64 go build -ldflags "-X main.Version=$VERSION" -o micro-$1/micro ./cmd/micro
|
||||
GOOS=openbsd GOARCH=amd64 go build -ldflags "-X main.Version=$1 -X main.CommitHash=$HASH -X 'main.CompileDate=$(date -u '+%B %d, %Y')'" -o micro-$1/micro ./cmd/micro
|
||||
tar -czf micro-$1-openbsd64.tar.gz micro-$1
|
||||
mv micro-$1-openbsd64.tar.gz binaries
|
||||
echo "OpenBSD 32"
|
||||
GOOS=openbsd GOARCH=386 go build -ldflags "-X main.Version=$VERSION" -o micro-$1/micro ./cmd/micro
|
||||
GOOS=openbsd GOARCH=386 go build -ldflags "-X main.Version=$1 -X main.CommitHash=$HASH -X 'main.CompileDate=$(date -u '+%B %d, %Y')'" -o micro-$1/micro ./cmd/micro
|
||||
tar -czf micro-$1-openbsd32.tar.gz micro-$1
|
||||
mv micro-$1-openbsd32.tar.gz binaries
|
||||
|
||||
# FreeBSD
|
||||
echo "FreeBSD 64"
|
||||
GOOS=freebsd GOARCH=amd64 go build -ldflags "-X main.Version=$VERSION" -o micro-$1/micro ./cmd/micro
|
||||
GOOS=freebsd GOARCH=amd64 go build -ldflags "-X main.Version=$1 -X main.CommitHash=$HASH -X 'main.CompileDate=$(date -u '+%B %d, %Y')'" -o micro-$1/micro ./cmd/micro
|
||||
tar -czf micro-$1-freebsd64.tar.gz micro-$1
|
||||
mv micro-$1-freebsd64.tar.gz binaries
|
||||
echo "FreeBSD 32"
|
||||
GOOS=freebsd GOARCH=386 go build -ldflags "-X main.Version=$VERSION" -o micro-$1/micro ./cmd/micro
|
||||
GOOS=freebsd GOARCH=386 go build -ldflags "-X main.Version=$1 -X main.CommitHash=$HASH -X 'main.CompileDate=$(date -u '+%B %d, %Y')'" -o micro-$1/micro ./cmd/micro
|
||||
tar -czf micro-$1-freebsd32.tar.gz micro-$1
|
||||
mv micro-$1-freebsd32.tar.gz binaries
|
||||
|
||||
@@ -62,11 +62,11 @@ rm micro-$1/micro
|
||||
|
||||
# Windows
|
||||
echo "Windows 64"
|
||||
GOOS=windows GOARCH=amd64 go build -ldflags "-X main.Version=$VERSION" -o micro-$1/micro.exe ./cmd/micro
|
||||
GOOS=windows GOARCH=amd64 go build -ldflags "-X main.Version=$1 -X main.CommitHash=$HASH -X 'main.CompileDate=$(date -u '+%B %d, %Y')'" -o micro-$1/micro.exe ./cmd/micro
|
||||
zip -r -q -T micro-$1-win64.zip micro-$1
|
||||
mv micro-$1-win64.zip binaries
|
||||
echo "Windows 32"
|
||||
GOOS=windows GOARCH=386 go build -ldflags "-X main.Version=$VERSION" -o micro-$1/micro.exe ./cmd/micro
|
||||
GOOS=windows GOARCH=386 go build -ldflags "-X main.Version=$1 -X main.CommitHash=$HASH -X 'main.CompileDate=$(date -u '+%B %d, %Y')'" -o micro-$1/micro.exe ./cmd/micro
|
||||
zip -r -q -T micro-$1-win32.zip micro-$1
|
||||
mv micro-$1-win32.zip binaries
|
||||
|
||||
|
||||
117
tools/pre-release.sh
Executable file
117
tools/pre-release.sh
Executable file
@@ -0,0 +1,117 @@
|
||||
# This script creates releases on Github for micro
|
||||
# It assumes that the binaries are in the current directory
|
||||
# You must have the correct Github access token to run this script
|
||||
|
||||
# $1 is the title, $2 is the description
|
||||
|
||||
commitID=$(git rev-parse HEAD)
|
||||
tag="v$1"
|
||||
|
||||
echo "Creating tag"
|
||||
git tag $tag $commitID
|
||||
git push --tags
|
||||
|
||||
echo "Creating new release"
|
||||
github-release release \
|
||||
--user zyedidia \
|
||||
--repo micro \
|
||||
--tag $tag \
|
||||
--name "$1" \
|
||||
--description "$2" \
|
||||
--pre-release
|
||||
|
||||
echo "Uploading OSX binary"
|
||||
github-release upload \
|
||||
--user zyedidia \
|
||||
--repo micro \
|
||||
--tag $tag \
|
||||
--name "micro-$1-osx.tar.gz" \
|
||||
--file binaries/micro-$1-osx.tar.gz
|
||||
|
||||
echo "Uploading Linux 64 binary"
|
||||
github-release upload \
|
||||
--user zyedidia \
|
||||
--repo micro \
|
||||
--tag $tag \
|
||||
--name "micro-$1-linux64.tar.gz" \
|
||||
--file binaries/micro-$1-linux64.tar.gz
|
||||
|
||||
echo "Uploading Linux 32 binary"
|
||||
github-release upload \
|
||||
--user zyedidia \
|
||||
--repo micro \
|
||||
--tag $tag \
|
||||
--name "micro-$1-linux32.tar.gz" \
|
||||
--file binaries/micro-$1-linux32.tar.gz
|
||||
|
||||
echo "Uploading Linux Arm binary"
|
||||
github-release upload \
|
||||
--user zyedidia \
|
||||
--repo micro \
|
||||
--tag $tag \
|
||||
--name "micro-$1-linux-arm.tar.gz" \
|
||||
--file binaries/micro-$1-linux-arm.tar.gz
|
||||
|
||||
echo "Uploading FreeBSD 64 binary"
|
||||
github-release upload \
|
||||
--user zyedidia \
|
||||
--repo micro \
|
||||
--tag $tag \
|
||||
--name "micro-$1-freebsd64.tar.gz" \
|
||||
--file binaries/micro-$1-freebsd64.tar.gz
|
||||
|
||||
echo "Uploading FreeBSD 32 binary"
|
||||
github-release upload \
|
||||
--user zyedidia \
|
||||
--repo micro \
|
||||
--tag $tag \
|
||||
--name "micro-$1-freebsd32.tar.gz" \
|
||||
--file binaries/micro-$1-freebsd32.tar.gz
|
||||
|
||||
echo "Uploading OpenBSD 64 binary"
|
||||
github-release upload \
|
||||
--user zyedidia \
|
||||
--repo micro \
|
||||
--tag $tag \
|
||||
--name "micro-$1-openbsd64.tar.gz" \
|
||||
--file binaries/micro-$1-openbsd64.tar.gz
|
||||
|
||||
echo "Uploading OpenBSD 32 binary"
|
||||
github-release upload \
|
||||
--user zyedidia \
|
||||
--repo micro \
|
||||
--tag $tag \
|
||||
--name "micro-$1-openbsd32.tar.gz" \
|
||||
--file binaries/micro-$1-openbsd32.tar.gz
|
||||
|
||||
echo "Uploading NetBSD 64 binary"
|
||||
github-release upload \
|
||||
--user zyedidia \
|
||||
--repo micro \
|
||||
--tag $tag \
|
||||
--name "micro-$1-netbsd64.tar.gz" \
|
||||
--file binaries/micro-$1-netbsd64.tar.gz
|
||||
|
||||
echo "Uploading NetBSD 32 binary"
|
||||
github-release upload \
|
||||
--user zyedidia \
|
||||
--repo micro \
|
||||
--tag $tag \
|
||||
--name "micro-$1-netbsd32.tar.gz" \
|
||||
--file binaries/micro-$1-netbsd32.tar.gz
|
||||
|
||||
echo "Uploading Windows 64 binary"
|
||||
github-release upload \
|
||||
--user zyedidia \
|
||||
--repo micro \
|
||||
--tag $tag \
|
||||
--name "micro-$1-win64.zip" \
|
||||
--file binaries/micro-$1-win64.zip
|
||||
|
||||
echo "Uploading Windows 32 binary"
|
||||
github-release upload \
|
||||
--user zyedidia \
|
||||
--repo micro \
|
||||
--tag $tag \
|
||||
--name "micro-$1-win32.zip" \
|
||||
--file binaries/micro-$1-win32.zip
|
||||
@@ -5,25 +5,25 @@
|
||||
# $1 is the title, $2 is the description
|
||||
|
||||
commitID=$(git rev-parse HEAD)
|
||||
tag="v$1"
|
||||
|
||||
echo "Creating tag"
|
||||
git tag $1 $commitID
|
||||
git tag $tag $commitID
|
||||
git push --tags
|
||||
|
||||
echo "Creating new release"
|
||||
github-release release \
|
||||
--user zyedidia \
|
||||
--repo micro \
|
||||
--tag $1 \
|
||||
--tag $tag \
|
||||
--name "$1" \
|
||||
--description "$2" \
|
||||
--pre-release
|
||||
|
||||
echo "Uploading OSX binary"
|
||||
github-release upload \
|
||||
--user zyedidia \
|
||||
--repo micro \
|
||||
--tag $1 \
|
||||
--tag $tag \
|
||||
--name "micro-$1-osx.tar.gz" \
|
||||
--file binaries/micro-$1-osx.tar.gz
|
||||
|
||||
@@ -31,7 +31,7 @@ echo "Uploading Linux 64 binary"
|
||||
github-release upload \
|
||||
--user zyedidia \
|
||||
--repo micro \
|
||||
--tag $1 \
|
||||
--tag $tag \
|
||||
--name "micro-$1-linux64.tar.gz" \
|
||||
--file binaries/micro-$1-linux64.tar.gz
|
||||
|
||||
@@ -39,7 +39,7 @@ echo "Uploading Linux 32 binary"
|
||||
github-release upload \
|
||||
--user zyedidia \
|
||||
--repo micro \
|
||||
--tag $1 \
|
||||
--tag $tag \
|
||||
--name "micro-$1-linux32.tar.gz" \
|
||||
--file binaries/micro-$1-linux32.tar.gz
|
||||
|
||||
@@ -47,7 +47,7 @@ echo "Uploading Linux Arm binary"
|
||||
github-release upload \
|
||||
--user zyedidia \
|
||||
--repo micro \
|
||||
--tag $1 \
|
||||
--tag $tag \
|
||||
--name "micro-$1-linux-arm.tar.gz" \
|
||||
--file binaries/micro-$1-linux-arm.tar.gz
|
||||
|
||||
@@ -55,7 +55,7 @@ echo "Uploading FreeBSD 64 binary"
|
||||
github-release upload \
|
||||
--user zyedidia \
|
||||
--repo micro \
|
||||
--tag $1 \
|
||||
--tag $tag \
|
||||
--name "micro-$1-freebsd64.tar.gz" \
|
||||
--file binaries/micro-$1-freebsd64.tar.gz
|
||||
|
||||
@@ -63,7 +63,7 @@ echo "Uploading FreeBSD 32 binary"
|
||||
github-release upload \
|
||||
--user zyedidia \
|
||||
--repo micro \
|
||||
--tag $1 \
|
||||
--tag $tag \
|
||||
--name "micro-$1-freebsd32.tar.gz" \
|
||||
--file binaries/micro-$1-freebsd32.tar.gz
|
||||
|
||||
@@ -71,7 +71,7 @@ echo "Uploading OpenBSD 64 binary"
|
||||
github-release upload \
|
||||
--user zyedidia \
|
||||
--repo micro \
|
||||
--tag $1 \
|
||||
--tag $tag \
|
||||
--name "micro-$1-openbsd64.tar.gz" \
|
||||
--file binaries/micro-$1-openbsd64.tar.gz
|
||||
|
||||
@@ -79,7 +79,7 @@ echo "Uploading OpenBSD 32 binary"
|
||||
github-release upload \
|
||||
--user zyedidia \
|
||||
--repo micro \
|
||||
--tag $1 \
|
||||
--tag $tag \
|
||||
--name "micro-$1-openbsd32.tar.gz" \
|
||||
--file binaries/micro-$1-openbsd32.tar.gz
|
||||
|
||||
@@ -87,7 +87,7 @@ echo "Uploading NetBSD 64 binary"
|
||||
github-release upload \
|
||||
--user zyedidia \
|
||||
--repo micro \
|
||||
--tag $1 \
|
||||
--tag $tag \
|
||||
--name "micro-$1-netbsd64.tar.gz" \
|
||||
--file binaries/micro-$1-netbsd64.tar.gz
|
||||
|
||||
@@ -95,7 +95,7 @@ echo "Uploading NetBSD 32 binary"
|
||||
github-release upload \
|
||||
--user zyedidia \
|
||||
--repo micro \
|
||||
--tag $1 \
|
||||
--tag $tag \
|
||||
--name "micro-$1-netbsd32.tar.gz" \
|
||||
--file binaries/micro-$1-netbsd32.tar.gz
|
||||
|
||||
@@ -103,7 +103,7 @@ echo "Uploading Windows 64 binary"
|
||||
github-release upload \
|
||||
--user zyedidia \
|
||||
--repo micro \
|
||||
--tag $1 \
|
||||
--tag $tag \
|
||||
--name "micro-$1-win64.zip" \
|
||||
--file binaries/micro-$1-win64.zip
|
||||
|
||||
@@ -111,6 +111,7 @@ echo "Uploading Windows 32 binary"
|
||||
github-release upload \
|
||||
--user zyedidia \
|
||||
--repo micro \
|
||||
--tag $1 \
|
||||
--tag $tag \
|
||||
--name "micro-$1-win32.zip" \
|
||||
--file binaries/micro-$1-win32.zip
|
||||
|
||||
|
||||
Reference in New Issue
Block a user