Skip to content

Commit

Permalink
splitwin work
Browse files Browse the repository at this point in the history
  • Loading branch information
kristofer committed Nov 24, 2018
1 parent 7484807 commit 80f3f37
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 138 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"editor.fontSize": 13,
"files.autoSave": "onFocusChange"
"files.autoSave": "afterDelay"
}
3 changes: 0 additions & 3 deletions tkg/bar

This file was deleted.

4 changes: 2 additions & 2 deletions tkg/buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (bp *Buffer) RuneAt(pt int) (rune, error) {
if npt := bp.dataPointForBufferPoint(pt); npt < len(bp.data) {
return bp.data[npt], nil
}
log.Println("RuneAt", pt, bp.BufferLen(), bp.ActualLen())
//log.Println("RuneAt", pt, bp.BufferLen(), bp.ActualLen())
return 0, errors.New("Ran over end of data buffer in RuneAt")
}

Expand Down Expand Up @@ -139,7 +139,7 @@ func (bp *Buffer) SetPoint(np int) {
bp.postLen++
}
if bp.PageEnd < bp.preLen {
log.Println("reframing!")
//log.Println("reframing!")
bp.Reframe = true
}
}
Expand Down
77 changes: 39 additions & 38 deletions tkg/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import (
"io/ioutil"
"log"
"strconv"
"strings"
"unicode"

termbox "github.com/nsf/termbox-go"
)

//type editFunc ((*Editor)func())

func (e *Editor) quit() { e.Done = true }
func (e *Editor) quitquit() {
e.EscapeFlag = false
Expand Down Expand Up @@ -74,9 +73,6 @@ func (e *Editor) yesno(flag bool, prompt string) bool {
e.MiniBufActive = true
defer func() { e.MiniBufActive = false }()
ev := <-e.EventChan
log.Println("Mini ev", ev)
// := e.HandleEvent(&ev)
// ch = getch();
ch := ev.Ch
if ch == '\r' || ch == '\n' {
return flag
Expand All @@ -85,13 +81,24 @@ func (e *Editor) yesno(flag bool, prompt string) bool {
return unicode.ToLower(ch) == 'y'
}

// func (e *Editor) redraw() {
// termbox.Clear(termbox.ColorDefault, termbox.ColorDefault)
// e.CurrentWindow.Updated = true
// e.CurrentBuffer.Reframe = true
// e.msg("editor redraw")
// e.updateDisplay()
// termbox.Sync()
// termbox.Flush()
// }
func (e *Editor) redraw() {

termbox.Clear(termbox.ColorDefault, termbox.ColorDefault)
e.CurrentWindow.Updated = true
e.CurrentBuffer.Reframe = true
e.msg("editor redraw")
for wp := e.RootWindow; wp != nil; wp = wp.Next {
wp.Updated = true
}
e.updateDisplay()
termbox.Flush()
}

func (e *Editor) left() {
Expand All @@ -105,20 +112,15 @@ func (e *Editor) right() {
func (e *Editor) wleft() {

}

func (e *Editor) pgdown() {

}

func (e *Editor) pgup() {
func (e *Editor) wright() {

}

func (e *Editor) wright() {
func (e *Editor) pgdown() {

}

func (e *Editor) insert() {
func (e *Editor) pgup() {

}

Expand Down Expand Up @@ -190,30 +192,30 @@ func (e *Editor) writefile() {
}

func (e *Editor) killBuffer() {
// buffer_t *kill_bp = curbp;
// buffer_t *bp;
// int bcount = count_buffers();

// /* do nothing if only buffer left is the scratch buffer */
// if (bcount == 1 && 0 == strcmp(get_buffer_name(curbp), "*scratch*"))
// return;

// if (curbp->b_flags & B_MODIFIED) {
// mvaddstr(MSGLINE, 0, "Discard changes (y/n) ?");
// clrtoeol();
// if (!yesno(FALSE))
// return;
// }
killbp := e.CurrentBuffer
bcount := e.CountBuffers()

// if (bcount == 1) {
// /* create a scratch buffer */
// bp = find_buffer("*scratch*", TRUE);
// strcpy(bp->b_bname, "*scratch*");
// }
// do nothing if only buffer left is the scratch buffer
if bcount == 1 && strings.Compare(e.GetBufferName(e.CurrentBuffer), "*scratch*") == 0 {
return
}

if e.CurrentBuffer.modified == true {
q := "Discard changes (y/n) ?"
if !e.yesno(false, q) {
return
}
}

// next_buffer();
// assert(kill_bp != curbp);
// delete_buffer(kill_bp);
if bcount == 1 {
bp := e.FindBuffer("*scratch*", true)
bp.Filename = "*scratch*"
}

e.nextBuffer()
if killbp != e.CurrentBuffer {
e.deleteBuffer(killbp)
}
}

func (e *Editor) iblock() {
Expand All @@ -234,7 +236,6 @@ func (e *Editor) killtoeol() {
}

func (e *Editor) copyCut(cut bool) {
/* if no mark or point == marker, nothing doing */
bp := e.CurrentBuffer
pt := bp.Point()
if bp.Mark == nomark || pt == bp.Mark {
Expand Down
Loading

0 comments on commit 80f3f37

Please sign in to comment.