Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QPlainTextEdit VT100 espace sequence support
Forum Updated to NodeBB v4.3 + New Features

QPlainTextEdit VT100 espace sequence support

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 5 Posters 3.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Fuchsiaff
    wrote on last edited by
    #1

    Hi, I am making a terminal widget with PyQt5 and I've come across several problems, one of them being that VT100 espace sequences show up like this

                              ./+o+-       bot@botnet
                      yyyyy- -yyyyyy+      OS: Ubuntu 18.10 cosmic
                   ://+//////-yyyyyyo      Kernel: x86_64 Linux 4.18.0-10-generic
               .++ .:/++++++/-.+sss/`      Uptime: 1d 15h 29m
             .:++o:  /++++++++/:--:/-      Packages: 2438
            o:+o+:++.`..```.-/oo+++++/     Shell: python3
           .:+o:+o/.          `+sssoo+/    Resolution: 1920x1080
      .++/+:+oo+o:`             /sssooo.   DE: KDE 5.50.0 / Plasma 5.13.5
     /+++//+:`oo+o               /::--:.   WM: KWin
     \+/+o+++`o++o               ++////.   GTK Theme: Breeze [GTK2/3]
      .++.o+++oo+:`             /dddhhh.   Icon Theme: breeze
           .+.o+oo:.          `oddhhhh+    Font: Noto Sans Regular
            \+.++o+o``-````.:ohdhhhhh+     CPU: Intel Core i7-4800MQ @ 8x 3.7GHz [51.0°C]
             `:o+++ `ohhhhhhhhyo++os:      GPU: intel
               .o:`.syhhhhhhh/.oo++o`      RAM: 2116MiB / 7667MiB
                   /osyyyyyyo++ooo+++/    
                       ````` +oo+++o\:    
                              `oo++.      
    

    I want my qplaintextedit to show the sequences like the linux terminal shows them in the terminal. How do I do that?

    aha_1980A JonBJ 2 Replies Last reply
    0
    • F Fuchsiaff

      Hi, I am making a terminal widget with PyQt5 and I've come across several problems, one of them being that VT100 espace sequences show up like this

                                ./+o+-       bot@botnet
                        yyyyy- -yyyyyy+      OS: Ubuntu 18.10 cosmic
                     ://+//////-yyyyyyo      Kernel: x86_64 Linux 4.18.0-10-generic
                 .++ .:/++++++/-.+sss/`      Uptime: 1d 15h 29m
               .:++o:  /++++++++/:--:/-      Packages: 2438
              o:+o+:++.`..```.-/oo+++++/     Shell: python3
             .:+o:+o/.          `+sssoo+/    Resolution: 1920x1080
        .++/+:+oo+o:`             /sssooo.   DE: KDE 5.50.0 / Plasma 5.13.5
       /+++//+:`oo+o               /::--:.   WM: KWin
       \+/+o+++`o++o               ++////.   GTK Theme: Breeze [GTK2/3]
        .++.o+++oo+:`             /dddhhh.   Icon Theme: breeze
             .+.o+oo:.          `oddhhhh+    Font: Noto Sans Regular
              \+.++o+o``-````.:ohdhhhhh+     CPU: Intel Core i7-4800MQ @ 8x 3.7GHz [51.0°C]
               `:o+++ `ohhhhhhhhyo++os:      GPU: intel
                 .o:`.syhhhhhhh/.oo++o`      RAM: 2116MiB / 7667MiB
                     /osyyyyyyo++ooo+++/    
                         ````` +oo+++o\:    
                                `oo++.      
      

      I want my qplaintextedit to show the sequences like the linux terminal shows them in the terminal. How do I do that?

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Fuchsiaff

      You could have a look at a class that we use in QtCreator: http://code.qt.io/cgit/qt-creator/qt-creator.git/tree/src/libs/utils/ansiescapecodehandler.cpp

      This class takes escape sequences and transforms them into a list of text with corresponding format.

      Later, in http://code.qt.io/cgit/qt-creator/qt-creator.git/tree/src/libs/utils/outputformatter.cpp#n77 this list is appended to the plain text edit with means of QTextCursor()

      This is of course no readymade solution, but should give you an idea how to do it.

      Regards

      Qt has to stay free or it will die.

      R 1 Reply Last reply
      4
      • F Fuchsiaff

        Hi, I am making a terminal widget with PyQt5 and I've come across several problems, one of them being that VT100 espace sequences show up like this

                                  ./+o+-       bot@botnet
                          yyyyy- -yyyyyy+      OS: Ubuntu 18.10 cosmic
                       ://+//////-yyyyyyo      Kernel: x86_64 Linux 4.18.0-10-generic
                   .++ .:/++++++/-.+sss/`      Uptime: 1d 15h 29m
                 .:++o:  /++++++++/:--:/-      Packages: 2438
                o:+o+:++.`..```.-/oo+++++/     Shell: python3
               .:+o:+o/.          `+sssoo+/    Resolution: 1920x1080
          .++/+:+oo+o:`             /sssooo.   DE: KDE 5.50.0 / Plasma 5.13.5
         /+++//+:`oo+o               /::--:.   WM: KWin
         \+/+o+++`o++o               ++////.   GTK Theme: Breeze [GTK2/3]
          .++.o+++oo+:`             /dddhhh.   Icon Theme: breeze
               .+.o+oo:.          `oddhhhh+    Font: Noto Sans Regular
                \+.++o+o``-````.:ohdhhhhh+     CPU: Intel Core i7-4800MQ @ 8x 3.7GHz [51.0°C]
                 `:o+++ `ohhhhhhhhyo++os:      GPU: intel
                   .o:`.syhhhhhhh/.oo++o`      RAM: 2116MiB / 7667MiB
                       /osyyyyyyo++ooo+++/    
                           ````` +oo+++o\:    
                                  `oo++.      
        

        I want my qplaintextedit to show the sequences like the linux terminal shows them in the terminal. How do I do that?

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @Fuchsiaff

        I am making a terminal widget with PyQt5

        Why? :)

        F 1 Reply Last reply
        0
        • JonBJ JonB

          @Fuchsiaff

          I am making a terminal widget with PyQt5

          Why? :)

          F Offline
          F Offline
          Fuchsiaff
          wrote on last edited by
          #4

          @JonB
          I am creating an IDE in python (https://github.com/Fuchsiaff/pypad) and I need a good terminal widget to provide interactive mode support but I need a terminal for that and there weren't any terminal widgets for PyQt5 so I decided to write my own.
          I still need to figure out how to interact with a process that's running but after I figure that out, my terminal should work just like a real terminal.

          JonBJ 1 Reply Last reply
          0
          • F Fuchsiaff

            @JonB
            I am creating an IDE in python (https://github.com/Fuchsiaff/pypad) and I need a good terminal widget to provide interactive mode support but I need a terminal for that and there weren't any terminal widgets for PyQt5 so I decided to write my own.
            I still need to figure out how to interact with a process that's running but after I figure that out, my terminal should work just like a real terminal.

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #5

            @Fuchsiaff
            Qt offers QProcess to spawn sub-processes, and you can access their stdin/out/err. But if you mean an "attach to process" like a debugger, I think you'd have to look at platform-specific calls.

            1 Reply Last reply
            1
            • F Offline
              F Offline
              Fuchsiaff
              wrote on last edited by
              #6

              Yeah, I am using QProcess but by interact with a running process I mean when you start a program using QProcess.start("python") then How do you write commands into that running process like in the cmd you write python and then you can write commands to the python shell

              jsulmJ 1 Reply Last reply
              0
              • F Fuchsiaff

                Yeah, I am using QProcess but by interact with a running process I mean when you start a program using QProcess.start("python") then How do you write commands into that running process like in the cmd you write python and then you can write commands to the python shell

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @Fuchsiaff Did you read http://doc.qt.io/qt-5/qprocess.html ? Especially "Communicating via Channels" part?

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                F 1 Reply Last reply
                1
                • jsulmJ jsulm

                  @Fuchsiaff Did you read http://doc.qt.io/qt-5/qprocess.html ? Especially "Communicating via Channels" part?

                  F Offline
                  F Offline
                  Fuchsiaff
                  wrote on last edited by
                  #8

                  @jsulm Nope, haven't really dug deeper into the problem since I'm trying to figure out how to unescape the ansii color codes.

                  JonBJ 1 Reply Last reply
                  0
                  • F Fuchsiaff

                    @jsulm Nope, haven't really dug deeper into the problem since I'm trying to figure out how to unescape the ansii color codes.

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by
                    #9

                    @Fuchsiaff
                    Just checking: you are sending the ESC character (ASCII 27) before the [ each time, aren't you?

                    I'm afraid there's no point asking me how/whether QPlainTextEdit handles these and whether it passes them through or not, I wouldn't know.

                    1 Reply Last reply
                    0
                    • aha_1980A aha_1980

                      @Fuchsiaff

                      You could have a look at a class that we use in QtCreator: http://code.qt.io/cgit/qt-creator/qt-creator.git/tree/src/libs/utils/ansiescapecodehandler.cpp

                      This class takes escape sequences and transforms them into a list of text with corresponding format.

                      Later, in http://code.qt.io/cgit/qt-creator/qt-creator.git/tree/src/libs/utils/outputformatter.cpp#n77 this list is appended to the plain text edit with means of QTextCursor()

                      This is of course no readymade solution, but should give you an idea how to do it.

                      Regards

                      R Offline
                      R Offline
                      Roman Bober
                      wrote on last edited by
                      #10

                      @aha_1980 thank you!

                      1 Reply Last reply
                      1

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved