Skip to content

Commit

Permalink
fixed modeline mouse click
Browse files Browse the repository at this point in the history
  • Loading branch information
kristofer committed Nov 18, 2021
1 parent 37561c2 commit 044e176
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 3 additions & 4 deletions buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package kg
import (
"errors"
"fmt"
"log"
)

/*
Expand Down Expand Up @@ -66,7 +65,7 @@ func (bp *Buffer) getText() string {

// RuneAt finally reliable!! (well, maybe not)
func (bp *Buffer) RuneAt(pt int) (rune, error) {
log.Println("RuneAt pt = ", pt)
//log.Println("RuneAt pt = ", pt)
if pt >= len(bp.data) {
return 0, errors.New("beyond data buffer in RuneAt")
}
Expand Down Expand Up @@ -107,15 +106,15 @@ func (bp *Buffer) SetPoint(np int) {
//bp.MoveGap(np - bp.Point)
// move gap <-(left) by np chars
gs := bp.gapStart()
log.Printf("gap start %d len %d new pt %d dist %d\n", gs, bp.gapLen(), np, gs-np)
//log.Printf("gap start %d len %d new pt %d dist %d\n", gs, bp.gapLen(), np, gs-np)
f := 0
for i := gs - np; i > 0; i-- {
bp.data[bp.postStart()-1] = bp.data[bp.Point-1]
bp.Point--
bp.postLen++
f++
}
log.Printf("shuffled %d\n", f)
//log.Printf("shuffled %d\n", f)

if bp.PageEnd < bp.Point {
bp.Reframe = true
Expand Down
6 changes: 5 additions & 1 deletion editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,13 @@ func (e *Editor) SetPointForMouse(mc, mr int) {
}

func (e *Editor) setWindowForMouse(mc, mr int) (c, r int) {
log.Printf("col %d row %d ", mc, mr)
log.Printf("setWindowForMouse col %d row %d ", mc, mr)

wp := e.RootWindow
// if mr is modeline or modeline+1, reduce to last wp.Rows
if mr > wp.Rows {
mr = wp.Rows
}
for wp != nil {
if (mr <= wp.Rows+wp.TopPt) && (mr >= wp.TopPt) {
log.Printf("set win rows %d top %d\n", wp.Rows, wp.TopPt)
Expand Down

0 comments on commit 044e176

Please sign in to comment.