Compare commits

..

21 Commits

Author SHA1 Message Date
Zachary Yedidia
dd5afc0560 Update readme 2017-08-08 11:08:57 -04:00
Zachary Yedidia
471486b531 Add newline after build tags 2017-08-07 09:47:28 -04:00
Zachary Yedidia
202cfb574c Only write settings if no error when reading
This commit also switches from yosuke-furukawa/json5 to flynn/json5
because yosuke-furukawa/json5 does not provide a license.

Ref zyedidia/json5#1

Closes #775
2017-08-06 12:02:17 -04:00
Zachary Yedidia
5c785ab1ac Fix MoveLines when user has a selection
Ref #767
2017-08-03 12:42:40 -04:00
Zachary Yedidia
2024b8b2c2 Merge pull request #767 from yannicka/master
Move current line down/up: cursor stay with moved line
2017-08-03 12:40:50 -04:00
Zachary Yedidia
86c695ca52 Merge pull request #758 from r15ch13/scoop
Add Scoop package manager list in readme
2017-08-03 12:17:36 -04:00
Yannick Armand
9dd1df36d5 Move current line down/up: cursor stay with moved line 2017-08-03 12:02:07 +02:00
Zachary Yedidia
27f99b6309 Merge pull request #764 from yannicka/master
OutdentSelection works on all cases (whatever tabsize or tabstospace values)
2017-08-01 21:15:16 -04:00
Yannick Armand
ed9bc66060 OutdentSelection works on all cases (whatever tabsize or tabstospace values) 2017-08-01 22:42:42 +02:00
Zachary Yedidia
d1598bb754 Merge pull request #762 from yannicka/master
Display number of lines in the JumpLine prompt
2017-08-01 12:03:51 -04:00
Yannick Armand
cc5855d07b Display number of lines in the JumpLine prompt 2017-08-01 16:41:57 +02:00
Zachary Yedidia
487b36f48f Update tcell
Ref #761
2017-08-01 10:12:10 -04:00
Zachary Yedidia
c0b00c9a4c Update tcell 2017-07-31 22:47:08 -04:00
Zachary Yedidia
86c2ac95bb Merge cursors after spawning with mouse
Fixes #760
2017-07-31 22:30:57 -04:00
Zachary Yedidia
edb79f2972 Merge 2017-07-31 22:24:46 -04:00
Zachary Yedidia
305cefe461 Update tcell 2017-07-31 22:24:42 -04:00
Zachary Yedidia
315391b0aa Expand support for Suspend to OSX, BSD, Solaris 2017-07-31 20:05:34 -04:00
Zachary Yedidia
fd45acc910 Remove unused variables 2017-07-31 18:46:52 -04:00
Richard Kuhnt
a574ae6b6a Add Scoop package manager list in readme 2017-07-30 13:51:17 +02:00
Zachary Yedidia
fa56a477c2 Merge 2017-07-29 14:45:53 -04:00
Zachary Yedidia
0db4556efb Update snap installation instructions 2017-07-29 14:45:49 -04:00
14 changed files with 117 additions and 37 deletions

6
.gitmodules vendored
View File

@@ -31,9 +31,6 @@
[submodule "cmd/micro/vendor/github.com/zyedidia/glob"]
path = cmd/micro/vendor/github.com/zyedidia/glob
url = https://github.com/zyedidia/glob
[submodule "cmd/micro/vendor/github.com/zyedidia/json5"]
path = cmd/micro/vendor/github.com/zyedidia/json5
url = https://github.com/zyedidia/json5
[submodule "cmd/micro/vendor/github.com/zyedidia/tcell"]
path = cmd/micro/vendor/github.com/zyedidia/tcell
url = https://github.com/zyedidia/tcell
@@ -55,3 +52,6 @@
[submodule "cmd/micro/vendor/github.com/zyedidia/poller"]
path = cmd/micro/vendor/github.com/zyedidia/poller
url = https://github.com/zyedidia/poller
[submodule "cmd/micro/vendor/github.com/flynn/json5"]
path = cmd/micro/vendor/github.com/flynn/json5
url = https://github.com/flynn/json5

View File

@@ -1106,3 +1106,61 @@ Exhibit B - "Incompatible With Secondary Licenses" Notice
This Source Code Form is "Incompatible With Secondary Licenses", as
defined by the Mozilla Public License, v. 2.0.
github.com/flynn/json5/LICENSE
================
Decoder code based on package encoding/json from the Go language.
Copyright (c) 2012 The Go Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Test data based on the parse cases from https://github.com/json5/json5
Copyright (c) 2012-2016 Aseem Kishore, and others.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -76,16 +76,22 @@ You can install micro using Homebrew on Mac:
brew install micro
```
On Windows, you can install micro through Chocolatey:
On Windows, you can install micro through [Chocolatey](https://chocolatey.org/) or [Scoop](https://github.com/lukesampson/scoop):
```
choco install micro
```
or
```
scoop install micro
```
On Linux, you can install micro through [snap](https://snapcraft.io/docs/core/install)
```
snap install micro --beta
snap install micro --edge --classic
```
### Building from source

View File

@@ -1,6 +1,7 @@
package main
import (
"fmt"
"os"
"strconv"
"strings"
@@ -785,19 +786,12 @@ func (v *View) OutdentSelection(usePlugin bool) bool {
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 && start.X > 0 {
v.Cursor.SetSelectionStart(start.Move(-1, v.Buf))
}
if y == endY {
v.Cursor.SetSelectionEnd(Loc{endX - x, endY})
}
}
}
v.Cursor.Relocate()
@@ -1154,12 +1148,16 @@ func (v *View) MoveLinesUp(usePlugin bool) bool {
messenger.Message("Can not move further up")
return true
}
start := v.Cursor.CurSelection[0].Y
end := v.Cursor.CurSelection[1].Y
if start > end {
end, start = start, end
}
v.Buf.MoveLinesUp(
v.Cursor.CurSelection[0].Y,
v.Cursor.CurSelection[1].Y,
start,
end,
)
v.Cursor.UpN(1)
v.Cursor.CurSelection[0].Y -= 1
v.Cursor.CurSelection[1].Y -= 1
messenger.Message("Moved up selected line(s)")
} else {
@@ -1171,7 +1169,6 @@ func (v *View) MoveLinesUp(usePlugin bool) bool {
v.Cursor.Loc.Y,
v.Cursor.Loc.Y+1,
)
v.Cursor.UpN(1)
messenger.Message("Moved up current line")
}
v.Buf.IsModified = true
@@ -1193,13 +1190,16 @@ func (v *View) MoveLinesDown(usePlugin bool) bool {
messenger.Message("Can not move further down")
return true
}
start := v.Cursor.CurSelection[0].Y
end := v.Cursor.CurSelection[1].Y
if start > end {
end, start = start, end
}
v.Buf.MoveLinesDown(
v.Cursor.CurSelection[0].Y,
v.Cursor.CurSelection[1].Y,
start,
end,
)
v.Cursor.DownN(1)
v.Cursor.CurSelection[0].Y += 1
v.Cursor.CurSelection[1].Y += 1
messenger.Message("Moved down selected line(s)")
} else {
if v.Cursor.Loc.Y >= len(v.Buf.lines)-1 {
@@ -1210,7 +1210,6 @@ func (v *View) MoveLinesDown(usePlugin bool) bool {
v.Cursor.Loc.Y,
v.Cursor.Loc.Y+1,
)
v.Cursor.DownN(1)
messenger.Message("Moved down current line")
}
v.Buf.IsModified = true
@@ -1479,7 +1478,8 @@ func (v *View) JumpLine(usePlugin bool) bool {
}
// Prompt for line number
linestring, canceled := messenger.Prompt("Jump to line # ", "", "LineNumber", NoCompletion)
message := fmt.Sprintf("Jump to line (1 - %v) # ", v.Buf.NumLines)
linestring, canceled := messenger.Prompt(message, "", "LineNumber", NoCompletion)
if canceled {
return false
}
@@ -1963,6 +1963,7 @@ func (v *View) MouseMultiCursor(usePlugin bool, e *tcell.EventMouse) bool {
v.Cursor = &v.Buf.Cursor
v.Buf.cursors = append(v.Buf.cursors, c)
v.Buf.MergeCursors()
v.Buf.UpdateCursors()
if usePlugin {

View File

@@ -1,4 +1,4 @@
// +build !linux
// +build android plan9 nacl windows
package main

View File

@@ -1,3 +1,5 @@
// +build linux darwin dragonfly solaris openbsd netbsd freebsd
package main
import "syscall"
@@ -19,8 +21,7 @@ func (v *View) Suspend(usePlugin bool) bool {
// suspend the process
pid := syscall.Getpid()
tid := syscall.Gettid()
err := syscall.Tgkill(pid, tid, syscall.SIGSTOP)
err := syscall.Kill(pid, syscall.SIGSTOP)
if err != nil {
TermMessage(err)
}

View File

@@ -5,7 +5,7 @@ import (
"os"
"strings"
"github.com/zyedidia/json5/encoding/json5"
"github.com/flynn/json5"
"github.com/zyedidia/tcell"
)

View File

@@ -21,8 +21,6 @@ import (
)
const (
synLinesUp = 75 // How many lines up to look to do syntax highlighting
synLinesDown = 75 // How many lines down to look to do syntax highlighting
doubleClickThreshold = 400 // How many milliseconds to wait before a second click is not a double click
undoThreshold = 500 // If two events are less than n milliseconds apart, undo both of them
autosaveTime = 8 // Number of seconds to wait before autosaving

View File

@@ -14,8 +14,8 @@ import (
"sync"
"github.com/blang/semver"
"github.com/flynn/json5"
"github.com/yuin/gopher-lua"
"github.com/zyedidia/json5/encoding/json5"
)
var (

View File

@@ -1,10 +1,11 @@
package main
import (
"github.com/blang/semver"
"testing"
"github.com/zyedidia/json5/encoding/json5"
"github.com/blang/semver"
"github.com/flynn/json5"
)
func TestDependencyResolving(t *testing.T) {

View File

@@ -1,6 +1,7 @@
package main
import (
"encoding/json"
"errors"
"io/ioutil"
"os"
@@ -8,8 +9,8 @@ import (
"strconv"
"strings"
"github.com/flynn/json5"
"github.com/zyedidia/glob"
"github.com/zyedidia/json5/encoding/json5"
)
type optionValidator func(string, interface{}) error
@@ -17,6 +18,8 @@ type optionValidator func(string, interface{}) error
// The options that the user can set
var globalSettings map[string]interface{}
var invalidSettings bool
// Options with validators
var optionValidators = map[string]optionValidator{
"tabsize": validatePositiveValue,
@@ -28,6 +31,7 @@ var optionValidators = map[string]optionValidator{
// InitGlobalSettings initializes the options map and sets all options to their default values
func InitGlobalSettings() {
invalidSettings = false
defaults := DefaultGlobalSettings()
var parsed map[string]interface{}
@@ -38,12 +42,14 @@ func InitGlobalSettings() {
if !strings.HasPrefix(string(input), "null") {
if err != nil {
TermMessage("Error reading settings.json file: " + err.Error())
invalidSettings = true
return
}
err = json5.Unmarshal(input, &parsed)
if err != nil {
TermMessage("Error reading settings.json:", err.Error())
invalidSettings = true
}
} else {
writeSettings = true
@@ -71,6 +77,7 @@ func InitGlobalSettings() {
// InitLocalSettings scans the json in settings.json and sets the options locally based
// on whether the buffer matches the glob
func InitLocalSettings(buf *Buffer) {
invalidSettings = false
var parsed map[string]interface{}
filename := configDir + "/settings.json"
@@ -78,12 +85,14 @@ func InitLocalSettings(buf *Buffer) {
input, err := ioutil.ReadFile(filename)
if err != nil {
TermMessage("Error reading settings.json file: " + err.Error())
invalidSettings = true
return
}
err = json5.Unmarshal(input, &parsed)
if err != nil {
TermMessage("Error reading settings.json:", err.Error())
invalidSettings = true
}
}
@@ -106,6 +115,11 @@ func InitLocalSettings(buf *Buffer) {
// WriteSettings writes the settings to the specified filename as JSON
func WriteSettings(filename string) error {
if invalidSettings {
// Do not write the settings if there was an error when reading them
return nil
}
var err error
if _, e := os.Stat(configDir); e == nil {
parsed := make(map[string]interface{})
@@ -124,6 +138,7 @@ func WriteSettings(filename string) error {
err = json5.Unmarshal(input, &parsed)
if err != nil {
TermMessage("Error reading settings.json:", err.Error())
invalidSettings = true
}
for k, v := range parsed {
@@ -136,7 +151,7 @@ func WriteSettings(filename string) error {
}
}
txt, _ := json5.MarshalIndent(parsed, "", " ")
txt, _ := json.MarshalIndent(parsed, "", " ")
err = ioutil.WriteFile(filename, append(txt, '\n'), 0644)
}
return err