Skip to content

Commit

Permalink
Merge branch 'master' into view-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
zyedidia committed Mar 27, 2017
2 parents 4cda7e2 + 53a19af commit 12d74b9
Show file tree
Hide file tree
Showing 47 changed files with 1,668 additions and 136 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ binaries/
tmp.sh
test/
.idea/
packages/
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Micro is licensed under the MIT "Expat" License:

Copyright (c) 2016: Zachary Yedidia.
Copyright (c) 2016: Zachary Yedidia, et al.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ If your operating system does not have a binary release, but does run Go, you ca
Make sure that you have Go version 1.5 or greater (Go 1.4 will work if your version supports CGO) and that your `GOPATH` env variable is set (I recommand setting it to `~/go` if you don't have one).

```
go get -d github.com/zyedidia/micro
go get -d github.com/zyedidia/micro/...
cd $GOPATH/src/github.com/zyedidia/micro
make install
```
Expand Down
34 changes: 23 additions & 11 deletions cmd/micro/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,14 +588,20 @@ func (v *View) IndentSelection(usePlugin bool) bool {
}

if v.Cursor.HasSelection() {
startY := v.Cursor.CurSelection[0].Y
endY := v.Cursor.CurSelection[1].Move(-1, v.Buf).Y
endX := v.Cursor.CurSelection[1].Move(-1, v.Buf).X
start := v.Cursor.CurSelection[0]
end := v.Cursor.CurSelection[1]
if end.Y < start.Y {
start, end = end, start
}

startY := start.Y
endY := end.Move(-1, v.Buf).Y
endX := end.Move(-1, v.Buf).X
for y := startY; y <= endY; y++ {
tabsize := len(v.Buf.IndentString())
v.Buf.Insert(Loc{0, y}, v.Buf.IndentString())
if y == startY && v.Cursor.CurSelection[0].X > 0 {
v.Cursor.SetSelectionStart(v.Cursor.CurSelection[0].Move(tabsize, v.Buf))
if y == startY && start.X > 0 {
v.Cursor.SetSelectionStart(start.Move(tabsize, v.Buf))
}
if y == endY {
v.Cursor.SetSelectionEnd(Loc{endX + tabsize + 1, endY})
Expand Down Expand Up @@ -643,17 +649,23 @@ func (v *View) OutdentSelection(usePlugin bool) bool {
}

if v.Cursor.HasSelection() {
startY := v.Cursor.CurSelection[0].Y
endY := v.Cursor.CurSelection[1].Move(-1, v.Buf).Y
endX := v.Cursor.CurSelection[1].Move(-1, v.Buf).X
start := v.Cursor.CurSelection[0]
end := v.Cursor.CurSelection[1]
if end.Y < start.Y {
start, end = end, start
}

startY := start.Y
endY := end.Move(-1, v.Buf).Y
endX := end.Move(-1, v.Buf).X
for y := startY; y <= endY; y++ {
for x := 0; x < len(v.Buf.IndentString()); x++ {
if len(GetLeadingWhitespace(v.Buf.Line(y))) == 0 {
break
}
v.Buf.Remove(Loc{0, y}, Loc{1, y})
if y == startY && v.Cursor.CurSelection[0].X > 0 {
v.Cursor.SetSelectionStart(v.Cursor.CurSelection[0].Move(-1, v.Buf))
if y == startY && start.X > 0 {
v.Cursor.SetSelectionStart(start.Move(-1, v.Buf))
}
if y == endY {
v.Cursor.SetSelectionEnd(Loc{endX - x, endY})
Expand Down Expand Up @@ -779,7 +791,7 @@ func (v *View) FindNext(usePlugin bool) bool {

if v.Cursor.HasSelection() {
searchStart = ToCharPos(v.Cursor.CurSelection[1], v.Buf)
lastSearch = v.Cursor.GetSelection()
// lastSearch = v.Cursor.GetSelection()
} else {
searchStart = ToCharPos(v.Cursor.Loc, v.Buf)
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/micro/bindings.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,8 @@ func DefaultBindings() map[string]string {
"CtrlV": "Paste",
"CtrlA": "SelectAll",
"CtrlT": "AddTab",
"CtrlRightSq": "PreviousTab",
"CtrlBackslash": "NextTab",
"Alt,": "PreviousTab",
"Alt.": "NextTab",
"Home": "StartOfLine",
"End": "EndOfLine",
"CtrlHome": "CursorStart",
Expand Down Expand Up @@ -444,6 +444,7 @@ func DefaultBindings() map[string]string {
// Integration with file managers
"F1": "ToggleHelp",
"F2": "Save",
"F3": "Find",
"F4": "Quit",
"F7": "Find",
"F10": "Quit",
Expand Down
32 changes: 30 additions & 2 deletions cmd/micro/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,13 @@ func VSplit(args []string) {
home, _ := homedir.Dir()
filename = strings.Replace(filename, "~", home, 1)
file, err := os.Open(filename)
fileInfo, _ := os.Stat(filename)

if err == nil && fileInfo.IsDir() {
messenger.Error(filename, " is a directory")
return
}

defer file.Close()

var buf *Buffer
Expand All @@ -349,6 +356,13 @@ func HSplit(args []string) {
home, _ := homedir.Dir()
filename = strings.Replace(filename, "~", home, 1)
file, err := os.Open(filename)
fileInfo, _ := os.Stat(filename)

if err == nil && fileInfo.IsDir() {
messenger.Error(filename, " is a directory")
return
}

defer file.Close()

var buf *Buffer
Expand Down Expand Up @@ -382,10 +396,24 @@ func NewTab(args []string) {
filename := args[0]
home, _ := homedir.Dir()
filename = strings.Replace(filename, "~", home, 1)
file, _ := os.Open(filename)
file, err := os.Open(filename)
fileInfo, _ := os.Stat(filename)

if err == nil && fileInfo.IsDir() {
messenger.Error(filename, " is a directory")
return
}

defer file.Close()

tab := NewTabFromView(NewView(NewBuffer(file, filename)))
var buf *Buffer
if err != nil {
buf = NewBuffer(strings.NewReader(""), filename)
} else {
buf = NewBuffer(file, filename)
}

tab := NewTabFromView(NewView(buf))
tab.SetNum(len(tabs))
tabs = append(tabs, tab)
curTab = len(tabs) - 1
Expand Down
582 changes: 567 additions & 15 deletions cmd/micro/runtime.go

Large diffs are not rendered by default.

19 changes: 12 additions & 7 deletions cmd/micro/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,13 @@ func (v *View) Open(filename string) {
home, _ := homedir.Dir()
filename = strings.Replace(filename, "~", home, 1)
file, err := os.Open(filename)
fileInfo, _ := os.Stat(filename)

if err == nil && fileInfo.IsDir() {
messenger.Error(filename, " is a directory")
return
}

defer file.Close()

var buf *Buffer
Expand Down Expand Up @@ -718,12 +725,6 @@ func (v *View) DisplayView() {

screenX = v.x

if v.x != 0 {
// Draw the split divider
screen.SetContent(screenX, yOffset+visualLineN, '|', nil, defStyle.Reverse(true))
screenX++
}

// If there are gutter messages we need to display the '>>' symbol here
if hasGutterMessages {
// msgOnLine stores whether or not there is a gutter message on this line in particular
Expand Down Expand Up @@ -891,8 +892,12 @@ func (v *View) DisplayView() {
}

if v.x != 0 && visualLineN < v.Height {
dividerStyle := defStyle
if style, ok := colorscheme["divider"]; ok {
dividerStyle = style
}
for i := visualLineN + 1; i < v.Height; i++ {
screen.SetContent(v.x, yOffset+i, '|', nil, defStyle.Reverse(true))
screen.SetContent(v.x, yOffset+i, '|', nil, dividerStyle.Reverse(true))
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions runtime/colorschemes/atom-dark-tc.micro
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ color-link underlined "#D33682,#1D1F21"
color-link error "bold #FF4444,#1D1F21"
color-link todo "bold #FF8844,#1D1F21"
color-link statusline "#1D1F21,#C5C8C6"
color-link tabbar "#1D1F21,#C5C8C6"
color-link indent-char "#505050,#1D1F21"
color-link line-number "#656866,#232526"
color-link current-line-number "#656866,#1D1F21"
color-link gutter-error "#FF4444,#1D1F21"
color-link gutter-warning "#EEEE77,#1D1F21"
color-link cursor-line "#2D2F31"
color-link color-column "#2D2F31"
#No extended types (bool in C, etc.)
color-link type.extended "default"
#Plain brackets
color-link symbol.brackets "default"
5 changes: 4 additions & 1 deletion runtime/colorschemes/bubblegum.micro
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ color-link special "167,231"
color-link error "231, 160"
color-link underlined "underline 241,231"
color-link todo "246,231"

color-link statusline "241,254"
color-link tabbar "241,254"
color-link gutter-error "197,231"
color-link gutter-warning "134,231"
color-link line-number "246,254"
color-link cursor-line "254"
color-link color-column "254"
#No extended types (bool in C, &c.) and plain brackets
color-link type.extended "default"
color-link symbol.brackets "default"
40 changes: 40 additions & 0 deletions runtime/colorschemes/cmc-16.micro
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#CaptainMcClellan's personal color scheme.
#16 colour version.
color-link comment "bold black"
color-link constant "cyan"
color-link constant.bool "bold cyan"
color-link constant.bool.true "bold green"
color-link constant.bool.false "bold red"
color-link constant.string "yellow"
color-link constant.string.url "underline blue, white"
#color-link constant.number "constant"
color-link constant.specialChar "bold magenta"
color-link identifier "bold red"
color-link identifier.macro "bold red"
color-link identifier.var "bold blue"
#color-link identifier.class "bold green"
color-link identifier.class "bold white"
color-link statement "bold yellow"
color-link symbol "red"
color-link symbol.brackets "blue"
color-link symbol.tag "bold blue"
color-link symbol.tag.extended "bold green"
color-link preproc "bold cyan"
color-link type "green"
color-link type.keyword "bold green"
color-link special "magenta"
color-link ignore "default"
color-link error "bold ,brightred"
color-link todo "underline black,brightyellow"
color-link indent-char ",brightgreen"
color-link line-number "green"
color-link line-number.scrollbar "green"
color-link statusline "white,blue"
color-link tabbar "white,blue"
color-link current-line-number "red"
color-link current-line-number.scroller "red"
color-link gutter-error ",red"
color-link gutter-warning "red"
color-link color-column "cyan"
color-link underlined.url "underline blue, white"
color-link divider "blue"
37 changes: 37 additions & 0 deletions runtime/colorschemes/cmc-paper.micro
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#CaptainMcClellan's personal color scheme.
#Paper version
color-link default "black,white"
color-link comment "bold black"
color-link constant "cyan"
color-link constant.bool "bold cyan"
color-link constant.bool.true "bold green"
color-link constant.bool.false "bold red"
color-link constant.string "bold yellow"
color-link constant.string.url "underline blue, white"
color-link constant.number "constant"
color-link constant.specialChar "bold magenta"
color-link identifier "bold red"
color-link identifier.macro "bold red"
color-link identifier.var "bold blue"
color-link identifier.class "bold green"
color-link preproc "bold cyan"
color-link statement "bold yellow"
color-link symbol "red"
color-link symbol.brackets "blue"
color-link type "green"
color-link type.keyword "bold green"
color-link special "magenta"
color-link ignore "default"
color-link error ",brightred"
color-link todo "black,brightyellow"
color-link indent-char ",brightgreen"
color-link line-number "green"
color-link line-number.scrollbar "green"
color-link statusline "white,blue"
color-link tabbar "white,blue"
color-link current-line-number "red"
color-link current-line-number.scroller "red"
color-link gutter-error ",red"
color-link gutter-warning "red"
color-link color-column "cyan"
color-link underlined.url "underline blue, white"
36 changes: 36 additions & 0 deletions runtime/colorschemes/cmc-tc.micro
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#CaptainMcClellan's personal colour scheme.
#Full colour edition.
color-link default "#aaaaaa,#1e2124"
color-link comment "bold #555555"
color-link constant "#008888"
#color-link constant.string "#888800"
color-link constant.string "#a85700"
color-link constant.specialChar "bold #ccccff"
color-link identifier "bold #e34234"
color-link identifier.macro "bold #e34234"
color-link identifier.var "bold #5757ff"
color-link identifier.class "bold #ffffff"
color-link statement "bold #ffff55"
color-link symbol "#722f37"
color-link symbol.brackets "#4169e1"
color-link symbol.tag "#5757ff"
color-link preproc "bold #55ffff"
color-link type "#3eb489"
color-link type.keyword "bold #bdecb6"
color-link special "#b57edc"
color-link ignore "default"
color-link error "bold ,#e34234"
color-link todo "bold underline #888888,#f26522"
color-link indent-char ",#bdecb6"
color-link line-number "#bdecb6,#36393e"
color-link line-number.scrollbar "#3eb489"
color-link statusline "#aaaaaa,#8a496b"
color-link tabbar "#aaaaaa,#8a496b"
color-link current-line-number "bold #e34234,#424549"
color-link current-line-number.scroller "red"
color-link gutter-error ",#e34234"
color-link gutter-warning "#e34234"
color-link color-column "#f26522"
color-link constant.bool "bold #55ffff"
color-link constant.bool.true "bold #85ff85"
color-link constant.bool.false "bold #ff8585"
25 changes: 25 additions & 0 deletions runtime/colorschemes/codeblocks-paper.micro
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#A colorscheme based on Code::Blocks IDE
#but with a white background.
color-link default "black,white"
color-link comment "bold black"
color-link constant "blue"
color-link constant.number "bold magenta"
color-link constant.string "bold blue"
color-link identifier "black"
color-link preproc "green"
color-link statement "blue"
color-link symbol "red"
color-link symbol.brackets "blue"
color-link type "blue"
color-link special "magenta"
color-link ignore "default"
color-link error "bold white,brightred"
color-link todo "bold black,brightyellow"
color-link indent-char "bold black"
color-link line-number "black,white"
color-link statusline "white,red"
color-link tabbar "white,red"
color-link current-line-number "red,black"
color-link gutter-error ",red"
color-link gutter-warning "red"
color-link color-column "black"
Loading

0 comments on commit 12d74b9

Please sign in to comment.