func (l Loc) GreaterThan(b Loc) bool {
	if l.Y > b.Y {
		return true
	}
	if l.Y == b.Y && l.X > b.X {
		return true
	}
	return false
}
GreaterThan returns true if b is bigger
package editor
func FromCharPos(loc int, buf *Buffer) Loc {
	charNum := 0
	x, y := 0, 0
	lineLen := Count(buf.Line(y)) + 1
	for charNum+lineLen <= loc {
		charNum += lineLen
		y++
		lineLen = Count(buf.Line(y)) + 1
	}
	x = loc - charNum
	return Loc{x, y}
}
func ToCharPos(start Loc, buf *Buffer) int {
	x, y := start.X, start.Y
	loc := 0
	for i := 0; i < y; i++ {
		loc += Count(buf.Line(i)) + 1
	}
	loc += x
	return loc
}
func InBounds(pos Loc, buf *Buffer) bool {
	if pos.Y < 0 || pos.Y >= buf.NumLines || pos.X < 0 || pos.X > Count(buf.Line(pos.Y)) {
		return false
	}
	return true
}
func ByteOffset(pos Loc, buf *Buffer) int {
	x, y := pos.X, pos.Y
	loc := 0
	for i := 0; i < y; i++ {
		loc += len(buf.Line(i)) + 1
	}
	loc += len(buf.Line(y)[:x])
	return loc
}
type Loc struct {
	X, Y int
}
func Diff(a, b Loc, buf *Buffer) int {
	if a.Y == b.Y {
		if a.X > b.X {
			return a.X - b.X
		}
		return b.X - a.X
	}
	if b.LessThan(a) {
		a, b = b, a
	}
	loc := 0
	for i := a.Y + 1; i < b.Y; i++ {
		loc += Count(buf.Line(i)) + 1
	}
	loc += Count(buf.Line(a.Y)) - a.X + b.X + 1
	return loc
}
func (l Loc) LessThan(b Loc) bool {
	if l.Y < b.Y {
		return true
	}
	if l.Y == b.Y && l.X < b.X {
		return true
	}
	return false
}