shithub: hell

Download patch

ref: 7235fc1225901e80e0058acdc3db9b67e9a36338
parent: b83f6b5d847be37e7f59faa1acac0d22ab3089bc
author: penny <penny@limitedideas.org>
date: Fri Nov 21 14:05:36 EST 2025

basic frame rendering

--- a/readline_plan9.go
+++ b/readline_plan9.go
@@ -6,6 +6,7 @@
 	"io"
 	"os"
 	"strings"
+	"image"
 
     "codeberg.org/penny64/go/draw"
 	"codeberg.org/penny64/go/draw/frame"
@@ -42,8 +43,37 @@
 	if err != nil {
 		return nil, err
 	}
+
+	var maincols [frame.NCOL]*draw.Image
+	/* Main text is yellowish */
+	screen := window.ScreenImage
+	maincols[frame.BACK] = window.AllocImageMix(draw.PaleYellow, draw.White)
+	maincols[frame.HIGH], _ = window.AllocImage(image.Rect(0, 0, 1, 1), screen.Pix, true, draw.DarkYellow)
+	maincols[frame.BORD], _ = window.AllocImage(image.Rect(0, 0, 2, 2), screen.Pix, true, draw.YellowGreen)
+	maincols[frame.TEXT] = window.Black
+	maincols[frame.HTEXT] = window.Black
+
+	const (
+		ScrollbarWidth = 12
+		BorderWidth    = 2
+	)
+	fullRect := window.ScreenImage.R
+	window.ScreenImage.Draw(fullRect, maincols[frame.BACK], nil, draw.ZP)
+	scrollRect := fullRect
+	scrollRect.Max.X = scrollRect.Min.X + ScrollbarWidth
+	textRect := fullRect
+	textRect.Min.X = scrollRect.Max.X
+	window.ScreenImage.Border(textRect, BorderWidth, maincols[frame.BORD], draw.ZP)
+	frameRect := textRect.Inset(BorderWidth)
 	f := &frame.Frame{}
-	f.Init(window.Image.R, window.Font, window.Image, nil)
+	f.Init(frameRect, window.Font, window.ScreenImage, maincols[:])
+	f.Insert([]rune("Hello, Frame!"), 0)
+	f.Display = window
+	f.InitTick()
+	f.Tick(f.PointOf(f.NumChars), true)
+	window.ScreenImage.Draw(scrollRect, maincols[frame.TEXT], nil, draw.ZP)
+
+	window.Flush()
 	label, err := os.OpenFile("/dev/label", os.O_WRONLY, 0)
 	return &readline{config: *config, ctl: nil, label: label}, nil
 }
--