Added OutdentLine action

This commit is contained in:
Jon Craton
2016-10-15 12:47:15 -04:00
parent fe0dce0960
commit cc9342df9d
2 changed files with 27 additions and 1 deletions

View File

@@ -610,6 +610,31 @@ func (v *View) IndentSelection(usePlugin bool) bool {
return false
}
// OutdentLine moves the current line back one indentation
func (v *View) OutdentLine(usePlugin bool) bool {
if usePlugin && !PreActionCall("OutdentLine", v) {
return false
}
if v.Cursor.HasSelection() {
return false
}
for x := 0; x < len(v.Buf.IndentString()); x++ {
if len(GetLeadingWhitespace(v.Buf.Line(v.Cursor.Y))) == 0 {
break
}
v.Buf.Remove(Loc{0, v.Cursor.Y}, Loc{1, v.Cursor.Y})
v.Cursor.X -= 1
}
v.Cursor.Relocate()
if usePlugin {
return PostActionCall("OutdentLine", v)
}
return true
}
// OutdentSelection takes the current selection and moves it back one indent level
func (v *View) OutdentSelection(usePlugin bool) bool {
if usePlugin && !PreActionCall("OutdentSelection", v) {

View File

@@ -56,6 +56,7 @@ var bindingActions = map[string]func(*View, bool) bool{
"MoveLinesDown": (*View).MoveLinesDown,
"IndentSelection": (*View).IndentSelection,
"OutdentSelection": (*View).OutdentSelection,
"OutdentLine": (*View).OutdentLine,
"Paste": (*View).Paste,
"PastePrimary": (*View).PastePrimary,
"SelectAll": (*View).SelectAll,
@@ -386,7 +387,7 @@ func DefaultBindings() map[string]string {
"Alt-CtrlH": "DeleteWordLeft",
"Alt-Backspace": "DeleteWordLeft",
"Tab": "IndentSelection,InsertTab",
"Backtab": "OutdentSelection",
"Backtab": "OutdentSelection,OutdentLine",
"CtrlO": "OpenFile",
"CtrlS": "Save",
"CtrlF": "Find",