Skip to content

Commit

Permalink
Moved lime/backend/primitives to github.com/quarnster/util/text
Browse files Browse the repository at this point in the history
  • Loading branch information
quarnster committed Oct 21, 2013
1 parent 3a2c708 commit 0a9f242
Show file tree
Hide file tree
Showing 45 changed files with 94 additions and 4,205 deletions.
2 changes: 1 addition & 1 deletion backend/commands/find.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package commands

import (
. "github.com/quarnster/util/text"
. "lime/backend"
. "lime/backend/primitives"
)

type (
Expand Down
24 changes: 12 additions & 12 deletions backend/commands/glue_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package commands

import (
"github.com/quarnster/util/text"
. "lime/backend"
"lime/backend/primitives"
"testing"
)

Expand All @@ -23,24 +23,24 @@ func TestGlueCmds(t *testing.T) {
ch.RunTextCommand(v, "glue_marked_undo_groups", nil)
if v.UndoStack().Position() != 1 {
t.Error(v.UndoStack().Position())
} else if d := v.Buffer().Substr(primitives.Region{0, v.Buffer().Size()}); d != "Hello World!\nTest123123\nAbrakadabra\nabc" {
} else if d := v.Buffer().Substr(text.Region{0, v.Buffer().Size()}); d != "Hello World!\nTest123123\nAbrakadabra\nabc" {
t.Error(d)
}
ch.RunTextCommand(v, "undo", nil)
if d := v.Buffer().Substr(primitives.Region{0, v.Buffer().Size()}); d != "Hello World!\nTest123123\nAbrakadabra\n" {
if d := v.Buffer().Substr(text.Region{0, v.Buffer().Size()}); d != "Hello World!\nTest123123\nAbrakadabra\n" {
t.Error(d)
}
ch.RunTextCommand(v, "redo", nil)
if d := v.Buffer().Substr(primitives.Region{0, v.Buffer().Size()}); d != "Hello World!\nTest123123\nAbrakadabra\nabc" {
if d := v.Buffer().Substr(text.Region{0, v.Buffer().Size()}); d != "Hello World!\nTest123123\nAbrakadabra\nabc" {
t.Error(d)
}
if v.UndoStack().Position() != 1 {
t.Error(v.UndoStack().Position())
} else if d := v.Buffer().Substr(primitives.Region{0, v.Buffer().Size()}); d != "Hello World!\nTest123123\nAbrakadabra\nabc" {
} else if d := v.Buffer().Substr(text.Region{0, v.Buffer().Size()}); d != "Hello World!\nTest123123\nAbrakadabra\nabc" {
t.Error(d)
}
ch.RunTextCommand(v, "undo", nil)
if d := v.Buffer().Substr(primitives.Region{0, v.Buffer().Size()}); d != "Hello World!\nTest123123\nAbrakadabra\n" {
if d := v.Buffer().Substr(text.Region{0, v.Buffer().Size()}); d != "Hello World!\nTest123123\nAbrakadabra\n" {
t.Error(d)
}

Expand All @@ -54,20 +54,20 @@ func TestGlueCmds(t *testing.T) {
ch.RunTextCommand(v, "glue_marked_undo_groups", nil)
if v.UndoStack().Position() != 1 {
t.Error(v.UndoStack().Position())
} else if d := v.Buffer().Substr(primitives.Region{0, v.Buffer().Size()}); d != "Hello World!\nTest123123\nAbrakadabra\nabc" {
} else if d := v.Buffer().Substr(text.Region{0, v.Buffer().Size()}); d != "Hello World!\nTest123123\nAbrakadabra\nabc" {
t.Error(d)
}
ch.RunTextCommand(v, "undo", nil)
if d := v.Buffer().Substr(primitives.Region{0, v.Buffer().Size()}); d != "Hello World!\nTest123123\nAbrakadabra\n" {
if d := v.Buffer().Substr(text.Region{0, v.Buffer().Size()}); d != "Hello World!\nTest123123\nAbrakadabra\n" {
t.Error(d)
}
ch.RunTextCommand(v, "redo", nil)
if d := v.Buffer().Substr(primitives.Region{0, v.Buffer().Size()}); d != "Hello World!\nTest123123\nAbrakadabra\nabc" {
if d := v.Buffer().Substr(text.Region{0, v.Buffer().Size()}); d != "Hello World!\nTest123123\nAbrakadabra\nabc" {
t.Error(d)
}
if v.UndoStack().Position() != 1 {
t.Error(v.UndoStack().Position())
} else if d := v.Buffer().Substr(primitives.Region{0, v.Buffer().Size()}); d != "Hello World!\nTest123123\nAbrakadabra\nabc" {
} else if d := v.Buffer().Substr(text.Region{0, v.Buffer().Size()}); d != "Hello World!\nTest123123\nAbrakadabra\nabc" {
t.Error(d)
}

Expand All @@ -82,14 +82,14 @@ func TestGlueCmds(t *testing.T) {
ch.RunTextCommand(v, "glue_marked_undo_groups", nil)
if v.UndoStack().Position() != 2 {
t.Error(v.UndoStack().Position())
} else if d := v.Buffer().Substr(primitives.Region{0, v.Buffer().Size()}); d != "Helabc" {
} else if d := v.Buffer().Substr(text.Region{0, v.Buffer().Size()}); d != "Helabc" {
t.Error(d)
}

ch.RunTextCommand(v, "undo", nil)
if v.UndoStack().Position() != 1 {
t.Error(v.UndoStack().Position())
} else if d := v.Buffer().Substr(primitives.Region{0, v.Buffer().Size()}); d != "Hello World!\nTest123123\nAbrakadabra\nabc" {
} else if d := v.Buffer().Substr(text.Region{0, v.Buffer().Size()}); d != "Hello World!\nTest123123\nAbrakadabra\nabc" {
t.Error(d)
}
}
4 changes: 2 additions & 2 deletions backend/commands/insdel.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package commands

import (
"fmt"
"github.com/quarnster/util/text"
. "lime/backend"
"lime/backend/primitives"
)

type (
Expand Down Expand Up @@ -66,7 +66,7 @@ func (c *LeftDeleteCommand) Run(v *View, e *Edit, args Args) error {
if prev_col < 0 {
prev_col = 0
}
d := v.Buffer().SubstrR(primitives.Region{prev_col, r.A})
d := v.Buffer().SubstrR(text.Region{prev_col, r.A})
i := len(d) - 1
for r.A > prev_col && i >= 0 && d[i] == ' ' {
r.A--
Expand Down
2 changes: 1 addition & 1 deletion backend/commands/insdel_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package commands

import (
. "github.com/quarnster/util/text"
. "lime/backend"
. "lime/backend/primitives"
"reflect"
"strings"
"testing"
Expand Down
22 changes: 11 additions & 11 deletions backend/commands/move.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package commands

import (
"fmt"
"github.com/quarnster/util/text"
. "lime/backend"
"lime/backend/primitives"
"lime/backend/util"
)

Expand All @@ -21,7 +21,7 @@ type (
}
)

func move_action(v *View, extend bool, transform func(r primitives.Region) int) {
func move_action(v *View, extend bool, transform func(r text.Region) int) {
sel := v.Sel()
r := sel.Regions()
for i := range r {
Expand All @@ -40,21 +40,21 @@ func (c *MoveToCommand) Run(v *View, e *Edit, args Args) error {

switch to {
case "eol":
move_action(v, extend, func(r primitives.Region) int {
move_action(v, extend, func(r text.Region) int {
line := v.Buffer().Line(r.B)
return line.B
})
case "bol":
move_action(v, extend, func(r primitives.Region) int {
move_action(v, extend, func(r text.Region) int {
line := v.Buffer().Line(r.B)
return line.A
})
case "bof":
move_action(v, extend, func(r primitives.Region) int {
move_action(v, extend, func(r text.Region) int {
return 0
})
case "eof":
move_action(v, extend, func(r primitives.Region) int {
move_action(v, extend, func(r text.Region) int {
return v.Buffer().Size()
})
default:
Expand Down Expand Up @@ -84,12 +84,12 @@ func (c *MoveCommand) Run(v *View, e *Edit, args Args) error {
if !fwd {
dir = -1
}
move_action(v, extend, func(r primitives.Region) int {
move_action(v, extend, func(r text.Region) int {
return r.B + dir
})
case "stops":
move_action(v, extend, func(r primitives.Region) int {
var next primitives.Region
move_action(v, extend, func(r text.Region) int {
var next text.Region
word := v.Buffer().Word(r.B)
if word_end && fwd && r.B < word.End() {
next = word
Expand All @@ -110,7 +110,7 @@ func (c *MoveCommand) Run(v *View, e *Edit, args Args) error {
return r.B
})
case "lines":
move_action(v, extend, func(in primitives.Region) int {
move_action(v, extend, func(in text.Region) int {
r, c := v.Buffer().RowCol(in.B)
_ = r
if !fwd {
Expand Down Expand Up @@ -153,7 +153,7 @@ func (c *ScrollLinesCommand) Run(v *View, e *Edit, args Args) error {
r -= amount
}
r = v.Buffer().TextPoint(r, 0)
fe.Show(v, primitives.Region{r, r})
fe.Show(v, text.Region{r, r})
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion backend/commands/move_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package commands

import (
. "github.com/quarnster/util/text"
. "lime/backend"
. "lime/backend/primitives"
"reflect"
"testing"
)
Expand Down
2 changes: 1 addition & 1 deletion backend/commands/undoredo_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package commands

import (
. "github.com/quarnster/util/text"
. "lime/backend"
. "lime/backend/primitives"
"testing"
)

Expand Down
2 changes: 1 addition & 1 deletion backend/editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package backend
import (
"code.google.com/p/log4go"
"fmt"
. "github.com/quarnster/util/text"
"io/ioutil"
"lime/backend/loaders"
. "lime/backend/primitives"
. "lime/backend/util"
"runtime"
"runtime/debug"
Expand Down
2 changes: 1 addition & 1 deletion backend/loaders/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
sj "encoding/json"
"errors"
"fmt"
. "github.com/quarnster/util/text"
"lime/backend/loaders/json"
. "lime/backend/primitives"
)

func LoadJSON(data []byte, intf interface{}) error {
Expand Down
16 changes: 8 additions & 8 deletions backend/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package parser
import (
"bytes"
"github.com/quarnster/parser"
"lime/backend/primitives"
"github.com/quarnster/util/text"
"sort"
"sync"
)
Expand All @@ -14,14 +14,14 @@ type (
}

NamedRegion struct {
primitives.Region
text.Region
Name string
}

SyntaxHighlighter interface {
ScopeExtent(point int) primitives.Region
ScopeExtent(point int) text.Region
ScopeName(point int) string
Flatten(viewport primitives.Region) []NamedRegion
Flatten(viewport text.Region) []NamedRegion
}

nodeHighlighter struct {
Expand Down Expand Up @@ -92,13 +92,13 @@ func (nh *nodeHighlighter) updateScope(point int) {
}
}

func (nh *nodeHighlighter) ScopeExtent(point int) primitives.Region {
func (nh *nodeHighlighter) ScopeExtent(point int) text.Region {
nh.updateScope(point)
if nh.lastScopeNode != nil {
r := nh.lastScopeNode.Range
return primitives.Region{r.Start, r.End}
return text.Region{r.Start, r.End}
}
return primitives.Region{}
return text.Region{}
}

func (nh *nodeHighlighter) ScopeName(point int) string {
Expand Down Expand Up @@ -129,6 +129,6 @@ func (nh *nodeHighlighter) flatten(in []NamedRegion, scopename string, node *par
return in
}

func (nh *nodeHighlighter) Flatten(viewport primitives.Region) []NamedRegion {
func (nh *nodeHighlighter) Flatten(viewport text.Region) []NamedRegion {
return nh.flatten(nil, "", nh.rootNode)
}
103 changes: 0 additions & 103 deletions backend/primitives/action.go

This file was deleted.

Loading

0 comments on commit 0a9f242

Please sign in to comment.