summaryrefslogtreecommitdiffstats
path: root/src/item.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2015-03-22 16:05:54 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2015-03-22 16:05:54 +0900
commitb431e227da318931a4e7458f3cc07616c6b74ea4 (patch)
tree78ea8c61a8399f27f268c58346cf1a5c97b5eed9 /src/item.go
parentd94dfe087694d68073f01a51c7357fc4741641d8 (diff)
Code cleanup
Diffstat (limited to 'src/item.go')
-rw-r--r--src/item.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/item.go b/src/item.go
index f9a464f0..c94166f2 100644
--- a/src/item.go
+++ b/src/item.go
@@ -7,7 +7,7 @@ import (
// Offset holds two 32-bit integers denoting the offsets of a matched substring
type Offset [2]int32
-type ColorOffset struct {
+type colorOffset struct {
offset [2]int32
color int
bold bool
@@ -20,7 +20,7 @@ type Item struct {
transformed *Transformed
index uint32
offsets []Offset
- colors []AnsiOffset
+ colors []ansiOffset
rank Rank
}
@@ -66,17 +66,17 @@ func (i *Item) AsString() string {
return *i.text
}
-func (item *Item) ColorOffsets(color int, bold bool, current bool) []ColorOffset {
+func (item *Item) colorOffsets(color int, bold bool, current bool) []colorOffset {
if len(item.colors) == 0 {
- offsets := make([]ColorOffset, 0)
+ var offsets []colorOffset
for _, off := range item.offsets {
- offsets = append(offsets, ColorOffset{offset: off, color: color, bold: bold})
+ offsets = append(offsets, colorOffset{offset: off, color: color, bold: bold})
}
return offsets
}
// Find max column
- var maxCol int32 = 0
+ var maxCol int32
for _, off := range item.offsets {
if off[1] > maxCol {
maxCol = off[1]
@@ -109,11 +109,11 @@ func (item *Item) ColorOffsets(color int, bold bool, current bool) []ColorOffset
// --++++++++-- --++++++++++---
curr := 0
start := 0
- offsets := make([]ColorOffset, 0)
+ var offsets []colorOffset
add := func(idx int) {
if curr != 0 && idx > start {
if curr == -1 {
- offsets = append(offsets, ColorOffset{
+ offsets = append(offsets, colorOffset{
offset: Offset{int32(start), int32(idx)}, color: color, bold: bold})
} else {
ansi := item.colors[curr-1]
@@ -121,7 +121,7 @@ func (item *Item) ColorOffsets(color int, bold bool, current bool) []ColorOffset
if current {
bg = int(curses.DarkBG)
}
- offsets = append(offsets, ColorOffset{
+ offsets = append(offsets, colorOffset{
offset: Offset{int32(start), int32(idx)},
color: curses.PairFor(ansi.color.fg, bg),
bold: ansi.color.bold || bold})