~taiite/public-inbox

senpai: ui: casemap nicks for coloring v1 REJECTED

Alexey Yerin: 1
 ui: casemap nicks for coloring

 1 files changed, 4 insertions(+), 0 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~taiite/public-inbox/patches/22959/mbox | git am -3
Learn more about email & git

[PATCH senpai] ui: casemap nicks for coloring Export this patch

Prior to this, sending messages to a user with different letter case
(though this is the same user) was appearing in different colors.

Fixes #61
---
 ui/style.go | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/ui/style.go b/ui/style.go
index d86e9f4..f1166f3 100644
--- a/ui/style.go
+++ b/ui/style.go
@@ -3,6 +3,8 @@ package ui
import (
	"hash/fnv"

	"git.sr.ht/~taiite/senpai/irc"

	"github.com/gdamore/tcell/v2"
	"github.com/mattn/go-runewidth"
)
@@ -232,6 +234,8 @@ var identColorBlacklist = []int{
}

func IdentColor(s string) (code int) {
	s = irc.CasemapRFC1459(s)

	h := fnv.New32()
	_, _ = h.Write([]byte(s))

-- 
2.31.1
While this will work in most cases, this doesn't use the casemapping
provided by the server and I'd like to move IRC-specific code out of
the ui module.

I'm currently working on a simpler version of android's AnnotatedString
that will contain what's necessary to keep track of colors and text
styles in a string.

https://android.googlesource.com/platform/frameworks/support/+/refs/heads/androidx-main/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/AnnotatedString.kt

Once that's done, ui.Line will need to be changed so that the head
color will be of type tcell.Color.

After that, the app module will be able to put ANSI codes in the
timeline and casemap nicks before setting the head color.