awesome-gocui / gocui

Minimalist Go package aimed at creating Console User Interfaces.
BSD 3-Clause "New" or "Revised" License
350 stars 39 forks source link

[BUG] Italic and strikethrough doesn't seem to work #46

Open C0DK opened 5 years ago

C0DK commented 5 years ago

Describe the bug So i've been trying to produce italic font for quite some time, and trying to debug why it wouldn't display on my gocui application, but it seems to be a general problem with gocui - and I realized that you don't use neither in your example - so I realized the problem might be on your end. But i cant fathom what can possibly be the cause of it. To Reproduce

the following doesn't use strikethrough or italic on my end.

// Copyright 2014 The gocui Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

import (
    "fmt"
    "log"

    "github.com/awesome-gocui/gocui"
)

func main() {
    g, err := gocui.NewGui(gocui.OutputNormal, true)
    if err != nil {
        log.Panicln(err)
    }
    defer g.Close()

    g.SetManagerFunc(layout)

    if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil {
        log.Panicln(err)
    }

    if err := g.MainLoop(); err != nil && !gocui.IsQuit(err) {
        log.Panicln(err)
    }
}

func layout(g *gocui.Gui) error {
    maxX, maxY := g.Size()
    if v, err := g.SetView("colors", maxX/2-7, maxY/2-12, maxX/2+7, maxY/2+13, 0); err != nil {
        if !gocui.IsUnknownView(err) {
            return err
        }
        for i := 0; i <= 7; i++ {
            for _, j := range []int{1, 3, 4, 7, 9} {
                fmt.Fprintf(v, "Hello \033[3%d;%dmcolors!\033[0m\n", i, j)
            }
        }
        if _, err := g.SetCurrentView("colors"); err != nil {
            return err
        }
    }
    return nil
}

func quit(g *gocui.Gui, v *gocui.View) error {
    return gocui.ErrQuit
}

Expected behavior

ANSI italic and strikethrough works.

Screenshots image <- this picture should italic and strikethrough, but only has underscore and reverse Environment (please complete the following information):

C0DK commented 5 years ago

I assume it's because Termbox doesn't support it - though https://github.com/nsf/termbox-go/blob/5c94acc5e6eb520f1bcd183974e01171cc4c23b3/api_common.go#L155 - but it seems weird that they don't do that.. :/

mjarkk commented 5 years ago

From a quick search it seems like Italic and Strikethrough are not supported in some shells or work different and thus some shell will have wired art affects when using then, that's why they seem to be not supported.
And sadly we can't do a lot about it :(

But there is some hope, we are trying to switch to a different underlying library named tcell instaid of termbox to fix some issues like yours but this will take time and sadly strikethrough and italic are both not supported yet in tcell.
But because tcell is actively developed and there is an issue about it we might see this at some point supported in gocui but no promises.

If you want to know how far we are with switching to tcell and testing it see this PR: https://github.com/awesome-gocui/gocui/pull/45

C0DK commented 5 years ago

Yeah i saw that tcell had the same problem. Do you need any small development help regarding the switch to Tcell? i need to create another PR for my hacktoberfest, and would gladly help here.

It seems that tcell have an open fork with both strikethrough and italic, so maybe we'll see it soon. i hope :D

mjarkk commented 5 years ago

If you want to help with #45 a pr is always welcome!
On the top of #45 there is a list of issues I've found and not yet fixed, if you want to help you could try to fix one of those or try to get an example project to work perfectly.

Make sure to fork my fork and create a pr there, the tcell branch was created in my fork to keep this repo clean

C0DK commented 5 years ago

will do!

MichaelMure commented 5 years ago

Completely unrelated to this particular issue, but I just wanted to drop by and say that it's awesome to see you guys organize and fill the gap to push gocui further. Very much appreciated :heart: