shithub: hell

Download patch

ref: 66998230f11db4d7949929fa6495bd8d5d043235
parent: 49229c7b8395a72150f35e4032be5d5e599d5f54
author: penny <penny@limitedideas.org>
date: Sat Oct 25 16:10:28 EDT 2025

add multiline support to plan 9

--- a/help.go
+++ b/help.go
@@ -10,6 +10,8 @@
   Config file location: %s
   
   ctrl-j                       Enable and disable multi-line mode
+                               Plan 9: ctrl-d , also toggles hold mode
+
   /help                        Show this help message.
   /reply <index> content       Reply to status by index.
   /like <index>                Favorite status by index.
--- a/readline_plan9.go
+++ b/readline_plan9.go
@@ -17,6 +17,8 @@
 
 type readline struct {
 	config Config
+	multi bool
+	ctl *os.File
 }
 
 type Config struct {
@@ -32,15 +34,38 @@
 }
 
 func NewReadline(config *Config) (*readline, error) {
-	return &readline{config: *config}, nil
+	ctl, err := os.OpenFile("/dev/consctl", os.O_WRONLY, 0)
+	if err != nil {
+		return nil, err
+	}
+	return &readline{config: *config, ctl: ctl}, nil
 }
 
+
 func (rl *readline) ReadLineWithConfig(cfg *Config) (string, error) {
 	fmt.Print(cfg.Prompt)
-	buffer := bufio.NewReader(os.Stdin)
-	scanner := bufio.NewScanner(buffer)
-	scanner.Scan()
-	return strings.TrimSpace(scanner.Text()), nil
+	var sb strings.Builder
+	for {
+		buffer := bufio.NewReader(os.Stdin)
+		input, err := buffer.ReadString('\n')
+		sb.WriteString(input)
+		if err != nil {
+			rl.multi = !rl.multi
+			if rl.multi {
+				fmt.Printf("MULTILINE %s", cfg.Prompt)
+				rl.ctl.WriteString("holdon")
+			}
+			// Avoid setting holdoff if we don't need to I guess
+			if !rl.multi {
+				rl.ctl.WriteString("holdoff")
+				break
+			}
+		}
+		if !rl.multi {
+			break
+		}
+	}
+	return strings.TrimSpace(sb.String()), nil
 }
 
 func (rl *readline) Stdout() io.Writer {
--