Loading ...
Sorry, an error occurred while loading the content.

Inverse and bold text in command line version

Expand Messages
  • marionbarryuk
    I d like to use bold and inverse text in an OS X command line app I am working on, but I have not been able to find the control code to do as such. Any hints?
    Message 1 of 8 , Nov 9, 2012
    • 0 Attachment
      I'd like to use bold and inverse text in an OS X command line app I am working on, but I have not been able to find the control code to do as such.

      Any hints?

      Thanks!

      Pete
    • jeffonymail
      Hi, Pete. Normally we are using ASCII text for which there is no provision for bold or italic. To add bold and italic you need to use some sort of convention
      Message 2 of 8 , Nov 11, 2012
      • 0 Attachment
        Hi, Pete.

        Normally we are using ASCII text for which there is no provision for bold or italic. To add bold and italic you need to use some sort of convention to add additional codes to the text to denote the font style. If it's just for your own use, you can design your own convention. Alternatively, and probably a better solution, is to use a pre-existing one.

        One convention you might take a look at is RTF (Rich Text Format) which uses the file suffix .rtf and is fairly well supported across word processors. Take a look at http://en.wikipedia.org/wiki/Rich_Text_Format for information on the specification.

        ....Jeff


        --- In chipmunkbasicforum@yahoogroups.com, marionbarryuk <no_reply@...> wrote:
        >
        > I'd like to use bold and inverse text in an OS X command line app I am working on, but I have not been able to find the control code to do as such.
        >
        > Any hints?
        >
        > Thanks!
        >
        > Pete
        >
      • jeffonymail
        Hi, Pete. After sending my previous reply I realized that a) you said inverse, not italic and b) maybe you meant the ability to draw text on the screen rather
        Message 3 of 8 , Nov 11, 2012
        • 0 Attachment
          Hi, Pete.

          After sending my previous reply I realized that a) you said inverse, not italic and b) maybe you meant the ability to draw text on the screen rather than to a file. I don't have any info on inverse text but below is a Chipmunk BASIC program that exercises some aspects of text drawing (such as bold and italic) to the screen. Details are in Chipmunk_Basic_Quick_Ref.txt

          xposdef=5 : yposdef=20 : lineheight=20 : gcr(0)
          font=0 : fontsize=14 : fontmode=8

          gTextSetup()
          for i=0 to -2 step -1
          gTextStyle(i)
          gCR(1)
          gPrint("i= " +Str$(i) + " Test string")
          next i
          end

          sub gTextSetup() : REM set font attributes
          graphics textsetup font, fontsize, fontmode
          end sub

          sub gTextStyle(fontstyle) : REM set font style
          graphics textsetup -1, fontstyle : REM 0 normal, -1 bold, -2 italic
          end sub

          sub GPRINT(a$) : REM draw the text
          graphics drawtext a$
          end sub

          sub gcr(linecnt,i) : REM if lineCnt=0 then clear screen else move down lineCnt lines
          if linecnt = 0
          cls : xpos = xposdef : ypos = yposdef
          else
          for i = 1 to linecnt : ypos = ypos+lineheight : next i
          endif
          xpos = xposdef : moveto xpos,ypos
          end sub


          Hope this helps.

          ....Jeff


          --- In chipmunkbasicforum@yahoogroups.com, marionbarryuk <no_reply@...> wrote:
          >
          > I'd like to use bold and inverse text in an OS X command line app I am working on, but I have not been able to find the control code to do as such.
          >
          > Any hints?
          >
          > Thanks!
          >
          > Pete
          >
        • Larr
          I used to do this stuff all the time when I was MUCH YOUNGER (I m now almost 50): Unfortunately, this sort of thing usually required knowledge of the terminal
          Message 4 of 8 , Nov 11, 2012
          • 0 Attachment
            I used to do this stuff all the time when I was MUCH YOUNGER (I'm now almost 50):

            Unfortunately, this sort of thing usually required knowledge of the terminal type that is being used.

            $ echo $TERM
            xterm-256color

            Here's the COMMAND LINE equivalent of what you're looking for:

            $ echo -e "\033[1mThis is a BOLD line\033[0m"

            MOST terminals observe the same sequence tho:

            Bold: <esc>[1m
            Plain: <esc>[0m

            Check out this URL for more escape sequences:

            http://www.isthe.com/chongo/tech/comp/ansi_escapes.html

            Replace Spaces with DOTS/PERIODS:

            www isthe com/chongo/tech/comp/ansi_escapes html

            Again, these sequences MAY or MAY NOT be 100% compatible with the terminal type in use.

            I _USED_ to have a 'screen generator' that you would feed a screen file too and it would paint the screen with protected labels. The BASIC program would call it the screen generator to paint the labels and then would perform input/positioning/etc... eventually clearing the protected values when done gathering input values.

            Larr.

            --- In chipmunkbasicforum@yahoogroups.com, marionbarryuk <no_reply@...> wrote:
            >
            > I'd like to use bold and inverse text in an OS X command line app I am working on, but I have not been able to find the control code to do as such.
            >
            > Any hints?
            >
            > Thanks!
            >
            > Pete
            >
          • marionbarryuk
            Thanks, that is what I was looking for!
            Message 5 of 8 , Nov 13, 2012
            • 0 Attachment
              Thanks, that is what I was looking for!

              --- In chipmunkbasicforum@yahoogroups.com, "Larr" <larrh@...> wrote:
              >
              > I used to do this stuff all the time when I was MUCH YOUNGER (I'm now almost 50):
              >
              > Unfortunately, this sort of thing usually required knowledge of the terminal type that is being used.
              >
              > $ echo $TERM
              > xterm-256color
              >
              > Here's the COMMAND LINE equivalent of what you're looking for:
              >
              > $ echo -e "\033[1mThis is a BOLD line\033[0m"
              >
              > MOST terminals observe the same sequence tho:
              >
              > Bold: <esc>[1m
              > Plain: <esc>[0m
              >
              > Check out this URL for more escape sequences:
              >
              > http://www.isthe.com/chongo/tech/comp/ansi_escapes.html
              >
              > Replace Spaces with DOTS/PERIODS:
              >
              > www isthe com/chongo/tech/comp/ansi_escapes html
              >
              > Again, these sequences MAY or MAY NOT be 100% compatible with the terminal type in use.
              >
              > I _USED_ to have a 'screen generator' that you would feed a screen file too and it would paint the screen with protected labels. The BASIC program would call it the screen generator to paint the labels and then would perform input/positioning/etc... eventually clearing the protected values when done gathering input values.
              >
              > Larr.
              >
              > --- In chipmunkbasicforum@yahoogroups.com, marionbarryuk <no_reply@> wrote:
              > >
              > > I'd like to use bold and inverse text in an OS X command line app I am working on, but I have not been able to find the control code to do as such.
              > >
              > > Any hints?
              > >
              > > Thanks!
              > >
              > > Pete
              > >
              >
            • jewisonc
              I think what he is referring to is shown in the small example program below Now in-order for this to work you need a Mac Teminal console app that can display
              Message 6 of 8 , Nov 14, 2012
              • 0 Attachment
                I think what he is referring to is shown in the small example program below
                Now in-order for this to work you need a Mac Teminal console app that can display ansii colour codes.

                Look in the App store for Cathode an interesting app that will take many of you far back in time.

                1 cls
                2 'Display Message In reverse Red
                10 print att$("7","31","40")+"Message"
                12 ' Reset Attributes to Green on Black background
                20 print att$("0","32","40")
                999 stop

                1000 'at$ 0=off,1=Bold,2=Low Intensity,4=underline,5=blink,7=Reverse
                1001 'Foreground Colour
                1002 'fg$ 30=black,31=red,32=Green,33=yellow,34=Blue,35=Magenta,36=Cyan,37=White
                1003 'Background Colour
                1004 'bg$ 30=black,31=red,32=Green,33=yellow,34=Blue,35=Magenta,36=Cyan,37=White
                1005 'Escape sequence used esc[mode;foreground code;background codem
                1006 'Note the 'm" character is required at the end of the string
                2000 sub att$ (at$,fg$,bg$)
                2020 att$ = chr$(27)+"["+at$+";"+fg$+";"+bg$+"m"
                2030 end sub
                2035'
                2036'Source for Ascii Info
                2037'http://ascii-table.com/ansi-escape-sequences.php

                --- In chipmunkbasicforum@yahoogroups.com, "Larr" <larrh@...> wrote:
                >
                > I used to do this stuff all the time when I was MUCH YOUNGER (I'm now almost 50):
                >
                > Unfortunately, this sort of thing usually required knowledge of the terminal type that is being used.
                >
                > $ echo $TERM
                > xterm-256color
                >
                > Here's the COMMAND LINE equivalent of what you're looking for:
                >
                > $ echo -e "\033[1mThis is a BOLD line\033[0m"
                >
                > MOST terminals observe the same sequence tho:
                >
                > Bold: <esc>[1m
                > Plain: <esc>[0m
                >
                > Check out this URL for more escape sequences:
                >
                > http://www.isthe.com/chongo/tech/comp/ansi_escapes.html
                >
                > Replace Spaces with DOTS/PERIODS:
                >
                > www isthe com/chongo/tech/comp/ansi_escapes html
                >
                > Again, these sequences MAY or MAY NOT be 100% compatible with the terminal type in use.
                >
                > I _USED_ to have a 'screen generator' that you would feed a screen file too and it would paint the screen with protected labels. The BASIC program would call it the screen generator to paint the labels and then would perform input/positioning/etc... eventually clearing the protected values when done gathering input values.
                >
                > Larr.
                >
                > --- In chipmunkbasicforum@yahoogroups.com, marionbarryuk <no_reply@> wrote:
                > >
                > > I'd like to use bold and inverse text in an OS X command line app I am working on, but I have not been able to find the control code to do as such.
                > >
                > > Any hints?
                > >
                > > Thanks!
                > >
                > > Pete
                > >
                >
              • jewisonc
                In previous my message Line 1004 should read as below, it won t stop the program from working it just corrects the comment. 1004 bg$
                Message 7 of 8 , Nov 14, 2012
                • 0 Attachment
                  In previous my message Line 1004 should read as below, it won't stop the program from working it just corrects the comment.
                  1004 'bg$ 40=black,41=red,42=Green,43=yellow,44=Blue,45=Magenta,46=Cyan,47=White

                  --- In chipmunkbasicforum@yahoogroups.com, "Larr" <larrh@...> wrote:
                  >
                  > I used to do this stuff all the time when I was MUCH YOUNGER (I'm now almost 50):
                  >
                  > Unfortunately, this sort of thing usually required knowledge of the terminal type that is being used.
                  >
                  > $ echo $TERM
                  > xterm-256color
                  >
                  > Here's the COMMAND LINE equivalent of what you're looking for:
                  >
                  > $ echo -e "\033[1mThis is a BOLD line\033[0m"
                  >
                  > MOST terminals observe the same sequence tho:
                  >
                  > Bold: <esc>[1m
                  > Plain: <esc>[0m
                  >
                  > Check out this URL for more escape sequences:
                  >
                  > http://www.isthe.com/chongo/tech/comp/ansi_escapes.html
                  >
                  > Replace Spaces with DOTS/PERIODS:
                  >
                  > www isthe com/chongo/tech/comp/ansi_escapes html
                  >
                  > Again, these sequences MAY or MAY NOT be 100% compatible with the terminal type in use.
                  >
                  > I _USED_ to have a 'screen generator' that you would feed a screen file too and it would paint the screen with protected labels. The BASIC program would call it the screen generator to paint the labels and then would perform input/positioning/etc... eventually clearing the protected values when done gathering input values.
                  >
                  > Larr.
                  >
                  > --- In chipmunkbasicforum@yahoogroups.com, marionbarryuk <no_reply@> wrote:
                  > >
                  > > I'd like to use bold and inverse text in an OS X command line app I am working on, but I have not been able to find the control code to do as such.
                  > >
                  > > Any hints?
                  > >
                  > > Thanks!
                  > >
                  > > Pete
                  > >
                  >
                • Larr
                  And here s a bit of fun for you too (sets your command prompt - best viewed on a Black Terminal background) PS1= n [ e[0;36m ] h [ e[1;37m ] ::
                  Message 8 of 8 , Nov 15, 2012
                  • 0 Attachment
                    And here's a bit of fun for you too (sets your command prompt - best viewed on a Black Terminal background)

                    PS1='\n\[\e[0;36m\]\h \[\e[1;37m\] :: ${PWD}\n\u\[\e[1;34m\]`r=$?; test $r -ne 0 && echo " \[\e[1;31m\]ret:$r"`\[\e[m\] > '; export PS1

                    Here's what it does:
                    \n (CRLF)
                    <esc>[0;36m sets the color of the text to a shade of blue
                    \h (Hostname)
                    <esc>[1;37m sets color of text to bold white
                    :: (just two colons)
                    ${PWD} is the common working directory. You can also use \w but I like to see the full path and not things like "~" for $HOME
                    \n (CRLF)
                    \n (Username)
                    The code between the `r= ... ]ret:$r` does is check $? for 0. If non-zero display it in bold-red

                    Check out this web site for a good list of color code:

                    http://www.pixelbeat.org/docs/terminal_colours/

                    --- In chipmunkbasicforum@yahoogroups.com, marionbarryuk <no_reply@...> wrote:
                    >
                    > I'd like to use bold and inverse text in an OS X command line app I am working on, but I have not been able to find the control code to do as such.
                    >
                    > Any hints?
                    >
                    > Thanks!
                    >
                    > Pete
                    >
                  Your message has been successfully submitted and would be delivered to recipients shortly.