xterm.dart icon indicating copy to clipboard operation
xterm.dart copied to clipboard

Text weirdly spaced on Web

Open JHubi1 opened this issue 1 year ago • 4 comments

I tried to build an application for web and desktop that has a terminal.

On desktop (windows for me) it works just fine: Screenshot 2024-07-02 135051

But when I try to run the exact same app with the exact same code on web, this is shown: Screenshot 2024-07-02 135101 It's functional and works in general, but looks pretty ugly. I tried it in multiple browsers as well, but it doesn't work.

JHubi1 avatar Jul 02 '24 11:07 JHubi1

I have the same problem

giovanni-grieco avatar Aug 03 '24 13:08 giovanni-grieco

So i managed to solve this. turns out its just a font issue:

                    child: TerminalView(
                      terminal,
                      controller: terminalController,
                      autofocus: true,
                      backgroundOpacity: 1,
                      textStyle: TerminalStyle(
                        fontFamily: GoogleFonts.robotoMono().fontFamily!,
                        fontSize: 14,
                      ),
                    ),
                    ```
                    
This makes the trick

Sudakatux avatar Dec 09 '24 00:12 Sudakatux

This problem is still present on web in a WASM build - the font workaround works fine in a non-WASM build though.

sygem avatar Mar 04 '25 15:03 sygem

You can solve this problem by the following methods.

TerminalView(
    .......
    onKeyEvent: (FocusNode node, KeyEvent event) {
      if (!kIsWeb ||
            event is! KeyUpEvent ||
            event.logicalKey != LogicalKeyboardKey.space) {
          return KeyEventResult.ignored;
        }
        _terminal.textInput(' ');
        return KeyEventResult.handled;
    },
    .......
}

xxNull-lsk avatar Mar 09 '25 02:03 xxNull-lsk