Skip to content

Commit

Permalink
Colorize diff3 separator marker
Browse files Browse the repository at this point in the history
  • Loading branch information
mkchoi212 committed May 12, 2018
1 parent 2230b51 commit eb4a2ad
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</p>
<br>

I never really liked any of the `mergetools` out there so I made a simple program that does simple things… in a simple fashion.
I never really liked any of the `mergetools` out there so I made a program that is somewhat easy to use.

![](./assets/overview.png)

Expand All @@ -29,8 +29,6 @@ brew install fac

## 🔧 Using

> **Please note fac does NOT support diff3 merge conflict outputs yet!**
`fac` operates much like `git add -p` . It has a prompt input at the bottom of the screen where the user inputs various commands.

The commands have been preset to the following specifications
Expand Down
21 changes: 14 additions & 7 deletions conflict/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/alecthomas/chroma/formatters"
"github.com/alecthomas/chroma/lexers"
"github.com/alecthomas/chroma/styles"
"github.com/mkchoi212/fac/color"
)

var FileLines map[string][]string
Expand Down Expand Up @@ -45,21 +46,27 @@ func (c *Conflict) HighlightSyntax() error {
var it chroma.Iterator
var err error
buf := new(bytes.Buffer)
var colorLine string

tokenizer:
for i, block := range [][]string{c.LocalLines, c.IncomingLines} {
for _, line := range block {
if it, err = lexer.Tokenise(nil, line); err != nil {
break tokenizer
}
if err = formatter.Format(buf, style, it); err != nil {
break tokenizer
if IdentifyStyle(line) == diff3 {
colorLine = color.Red(color.Regular, line)
} else {
if it, err = lexer.Tokenise(nil, line); err != nil {
break tokenizer
}
if err = formatter.Format(buf, style, it); err != nil {
break tokenizer
}
colorLine = buf.String()
}

if i == 0 {
c.ColoredLocalLines = append(c.ColoredLocalLines, buf.String())
c.ColoredLocalLines = append(c.ColoredLocalLines, colorLine)
} else {
c.ColoredIncomingLines = append(c.ColoredIncomingLines, buf.String())
c.ColoredIncomingLines = append(c.ColoredIncomingLines, colorLine)
}
buf.Reset()
}
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"fmt"
"log"
"os"
"strings"

"github.com/jroimartin/gocui"
Expand Down Expand Up @@ -88,8 +89,7 @@ func parseInput(g *gocui.Gui, v *gocui.View) error {
}

func main() {
//cwd, _ := os.Getwd()
cwd := "./assets/dummy_repo"
cwd, _ := os.Getwd()
conflicts, err := conflict.Find(cwd)
if err != nil {
fmt.Println(color.Red(color.Regular, err.Error()))
Expand Down

0 comments on commit eb4a2ad

Please sign in to comment.