shithub: hell

Download patch

ref: 1339339b7d7a5f7a9b5022574cf221f88bef08cb
parent: 724bed965adde24d6bf1e90b8bd4e8dcb94d40e7
author: penny <penny@limitedideas.org>
date: Fri Aug 8 22:01:08 EDT 2025

aasoteinarsoteiarst

--- a/format.go
+++ b/format.go
@@ -8,10 +8,18 @@
 
 func hyphenate(input string) string {
 	width := readline.GetScreenWidth()
+	return hyphenateWithWidth(input, width)
+}
+
+func hyphenateWithWidth(input string, width int) string {
 	var remainder = []rune(input)
 	var result []rune
 
-	for len(remainder) > width-1 {
+	if width < 2 {
+		return input
+	}
+
+	for len(remainder) > width {
 		if strings.HasPrefix(string(remainder), "\n") {
 			result = append(result, '\n')
 			remainder = remainder[1:]
@@ -26,11 +34,35 @@
 			continue
 		}
 
-		// otherwise we need to break the line
-		result = append(result, remainder[:width-1]...)
-		result = append(result, '\n')
-		remainder = remainder[width-1:]
+		if remainder[width-1] == ' ' {
+			result = append(result, remainder[:width-1]...)
+			result = append(result, '\n')
+			remainder = remainder[width:] // Consume the space
+		} else if remainder[width-1] == '-' {
+			result = append(result, remainder[:width]...)
+			result = append(result, '\n')
+			remainder = remainder[width:] // Consume the hyphen
+		} else {
+			result = append(result, remainder[:width-1]...)
+			result = append(result, '-')
+			remainder = remainder[width-1:]
+		}
 	}
+
 	result = append(result, remainder...)
 	return string(result)
+}
+
+func countEmoji(runes []rune) int {
+	count := 0
+	for _, r := range runes {
+		if isEmoji(r) {
+			count++
+		}
+	}
+	return count
+}
+
+func isEmoji(r rune) bool {
+	return r >= 0x1F600 && r <= 0x1F64F // Emoticons
 }
--