From 3da2a870b67bb65ed79c6ef174b0741fa1c04620 Mon Sep 17 00:00:00 2001 From: Camille Scholtz Date: Tue, 24 May 2016 21:38:46 +0200 Subject: [PATCH 1/5] make undothresthold a setting --- cmd/micro/micro.go | 12 ++++++++---- cmd/micro/settings.go | 23 ++++++++++++----------- runtime/help/help.md | 4 ++++ 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/cmd/micro/micro.go b/cmd/micro/micro.go index 718d220d..23818c67 100644 --- a/cmd/micro/micro.go +++ b/cmd/micro/micro.go @@ -17,10 +17,14 @@ 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 + // How many lines up to look to do syntax highlighting + synLinesUp = 75 + // How many lines down to look to do syntax highlighting + synLinesDown = 75 + // How many milliseconds to wait before a second click is not a double click + doubleClickThreshold = 400 + // If two events are less than n milliseconds apart, undo both of them + undoThreshold = int(settings["undothreshold"].(float64)) ) var ( diff --git a/cmd/micro/settings.go b/cmd/micro/settings.go index a9b1d358..8124a801 100644 --- a/cmd/micro/settings.go +++ b/cmd/micro/settings.go @@ -72,17 +72,18 @@ func GetOption(name string) interface{} { // DefaultSettings returns the default settings for micro func DefaultSettings() map[string]interface{} { return map[string]interface{}{ - "colorscheme": "default", - "tabsize": float64(4), - "indentchar": " ", - "ignorecase": false, - "autoindent": true, - "syntax": true, - "tabstospaces": false, - "ruler": true, - "statusline": true, - "scrollmargin": float64(3), - "scrollspeed": float64(2), + "autoindent": true, + "colorscheme": "default", + "ignorecase": false, + "indentchar": " ", + "ruler": true, + "scrollspeed": float64(2), + "scrollmargin": float64(3), + "statusline": true, + "syntax": true, + "tabsize": float64(4), + "tabstospaces": false, + "undothreshold": float64(500), } } diff --git a/runtime/help/help.md b/runtime/help/help.md index 3458f3ed..7961b5e4 100644 --- a/runtime/help/help.md +++ b/runtime/help/help.md @@ -203,6 +203,10 @@ Here are the options that you can set: default value: `on` +* `undothreshold`: maximum time in milliseconds events can be apart to be counted as a single undo + + default value: `500` + * `statusline`: display the status line at the bottom of the screen default value: `on` From e5538155011f13b346c4e4608974f3c0dc2bb845 Mon Sep 17 00:00:00 2001 From: Camille Scholtz Date: Tue, 24 May 2016 21:40:05 +0200 Subject: [PATCH 2/5] make undothresthold a setting (part 2) --- cmd/micro/eventhandler.go | 2 ++ cmd/micro/micro.go | 11 +++-------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/cmd/micro/eventhandler.go b/cmd/micro/eventhandler.go index 2c5076d1..de718731 100644 --- a/cmd/micro/eventhandler.go +++ b/cmd/micro/eventhandler.go @@ -115,6 +115,7 @@ func (eh *EventHandler) Undo() { te = t.(*TextEvent) + undoThreshold := int64(settings["undothreshold"].(float64)) if startTime-(te.time.UnixNano()/int64(time.Millisecond)) > undoThreshold { return } @@ -166,6 +167,7 @@ func (eh *EventHandler) Redo() { te = t.(*TextEvent) + undoThreshold := int64(settings["undothreshold"].(float64)) if (te.time.UnixNano()/int64(time.Millisecond))-startTime > undoThreshold { return } diff --git a/cmd/micro/micro.go b/cmd/micro/micro.go index 23818c67..cb24bf98 100644 --- a/cmd/micro/micro.go +++ b/cmd/micro/micro.go @@ -17,14 +17,9 @@ import ( ) const ( - // How many lines up to look to do syntax highlighting - synLinesUp = 75 - // How many lines down to look to do syntax highlighting - synLinesDown = 75 - // How many milliseconds to wait before a second click is not a double click - doubleClickThreshold = 400 - // If two events are less than n milliseconds apart, undo both of them - undoThreshold = int(settings["undothreshold"].(float64)) + 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 i not a double click ) var ( From 007ece1e78ea61cba40d5d801f9759e6e93574e8 Mon Sep 17 00:00:00 2001 From: Camille Scholtz Date: Thu, 26 May 2016 19:36:59 +0200 Subject: [PATCH 3/5] Add stackundo option --- cmd/micro/eventhandler.go | 4 ++++ cmd/micro/settings.go | 1 + runtime/help/help.md | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/cmd/micro/eventhandler.go b/cmd/micro/eventhandler.go index de718731..f4d816af 100644 --- a/cmd/micro/eventhandler.go +++ b/cmd/micro/eventhandler.go @@ -118,6 +118,10 @@ func (eh *EventHandler) Undo() { undoThreshold := int64(settings["undothreshold"].(float64)) if startTime-(te.time.UnixNano()/int64(time.Millisecond)) > undoThreshold { return + } else { + if settings["stackundo"] == true { + startTime = t.(*TextEvent).time.UnixNano() / int64(time.Millisecond) + } } eh.UndoOneEvent() diff --git a/cmd/micro/settings.go b/cmd/micro/settings.go index 8124a801..98f65d88 100644 --- a/cmd/micro/settings.go +++ b/cmd/micro/settings.go @@ -79,6 +79,7 @@ func DefaultSettings() map[string]interface{} { "ruler": true, "scrollspeed": float64(2), "scrollmargin": float64(3), + "stackundo": false, "statusline": true, "syntax": true, "tabsize": float64(4), diff --git a/runtime/help/help.md b/runtime/help/help.md index 7961b5e4..19c5bf14 100644 --- a/runtime/help/help.md +++ b/runtime/help/help.md @@ -211,6 +211,10 @@ Here are the options that you can set: default value: `on` +* `stackundo`: reset undothreshold timer to zero if an action is taken before the timer runs out + + default value: `off` + * `scrollmargin`: amount of lines you would like to see above and below the cursor default value: `3` From 1806ef3ad0cd2d1d36c7712fc2b4840d8f655c5a Mon Sep 17 00:00:00 2001 From: Camille Scholtz Date: Fri, 27 May 2016 23:39:27 +0200 Subject: [PATCH 4/5] Remove undo options, make stackundo default behavior --- cmd/micro/eventhandler.go | 6 +----- cmd/micro/micro.go | 1 + cmd/micro/settings.go | 24 +++++++++++------------- runtime/help/help.md | 8 -------- 4 files changed, 13 insertions(+), 26 deletions(-) diff --git a/cmd/micro/eventhandler.go b/cmd/micro/eventhandler.go index f4d816af..2e182c4c 100644 --- a/cmd/micro/eventhandler.go +++ b/cmd/micro/eventhandler.go @@ -115,13 +115,10 @@ func (eh *EventHandler) Undo() { te = t.(*TextEvent) - undoThreshold := int64(settings["undothreshold"].(float64)) if startTime-(te.time.UnixNano()/int64(time.Millisecond)) > undoThreshold { return } else { - if settings["stackundo"] == true { - startTime = t.(*TextEvent).time.UnixNano() / int64(time.Millisecond) - } + startTime = t.(*TextEvent).time.UnixNano() / int64(time.Millisecond) } eh.UndoOneEvent() @@ -171,7 +168,6 @@ func (eh *EventHandler) Redo() { te = t.(*TextEvent) - undoThreshold := int64(settings["undothreshold"].(float64)) if (te.time.UnixNano()/int64(time.Millisecond))-startTime > undoThreshold { return } diff --git a/cmd/micro/micro.go b/cmd/micro/micro.go index cb24bf98..d3661170 100644 --- a/cmd/micro/micro.go +++ b/cmd/micro/micro.go @@ -20,6 +20,7 @@ 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 i not a double click + undoThreshold = 500 // If two events are less than n milliseconds apart, undo both of them ) var ( diff --git a/cmd/micro/settings.go b/cmd/micro/settings.go index 98f65d88..4784da79 100644 --- a/cmd/micro/settings.go +++ b/cmd/micro/settings.go @@ -72,19 +72,17 @@ func GetOption(name string) interface{} { // DefaultSettings returns the default settings for micro func DefaultSettings() map[string]interface{} { return map[string]interface{}{ - "autoindent": true, - "colorscheme": "default", - "ignorecase": false, - "indentchar": " ", - "ruler": true, - "scrollspeed": float64(2), - "scrollmargin": float64(3), - "stackundo": false, - "statusline": true, - "syntax": true, - "tabsize": float64(4), - "tabstospaces": false, - "undothreshold": float64(500), + "autoindent": true, + "colorscheme": "default", + "ignorecase": false, + "indentchar": " ", + "ruler": true, + "scrollspeed": float64(2), + "scrollmargin": float64(3), + "statusline": true, + "syntax": true, + "tabsize": float64(4), + "tabstospaces": false, } } diff --git a/runtime/help/help.md b/runtime/help/help.md index 19c5bf14..3458f3ed 100644 --- a/runtime/help/help.md +++ b/runtime/help/help.md @@ -203,18 +203,10 @@ Here are the options that you can set: default value: `on` -* `undothreshold`: maximum time in milliseconds events can be apart to be counted as a single undo - - default value: `500` - * `statusline`: display the status line at the bottom of the screen default value: `on` -* `stackundo`: reset undothreshold timer to zero if an action is taken before the timer runs out - - default value: `off` - * `scrollmargin`: amount of lines you would like to see above and below the cursor default value: `3` From 00fe82e9c7c09bf2199fb738f3ff52b02fdbe9e4 Mon Sep 17 00:00:00 2001 From: Camille Date: Fri, 27 May 2016 23:39:53 +0200 Subject: [PATCH 5/5] Fix typo --- cmd/micro/micro.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/micro/micro.go b/cmd/micro/micro.go index d3661170..718d220d 100644 --- a/cmd/micro/micro.go +++ b/cmd/micro/micro.go @@ -19,7 +19,7 @@ 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 i not a double click + 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 )