Menu

#35 A new include file to colorize qout()

v1.0_(example)
open
nobody
None
1
2021-01-17
2021-01-12
No

Hi, Wilfried,

Can you add these files to HwGUI, and put qcolors.ch with other include files (to avoid such line type :

#include "./qcolor.ch"

qcolor.ch allows to send colored strings to the terminal, see qoutcolor.prg test program

I add too the script I use to use it in scripts.
Just put colors script in the path, for example /usr/local/bin or ~/bin
Add this line to .profile :
. colors <<< with a space between . and colors
and quit and open a new session
I used it since a long time ...

Some hints:
In hwgui, if you want to put colored string on colored background, put the foreground before the background
In scripts, using qcolor.ch from an hwgui program to create a linux script, doesn't work, you must use linux variable name. Using ${} allows to avoid having spage between variables and text ...
Example :

   if file("index.page")
      ctxt="#!/bin/bash"+chr(10)+chr(10)+ ;
           "echo -e ${gCya}"+_("Installing the yelp help of")+" ${gGre}hwmake${noColor}"+chr(10)+ ;
           'echo ""'+chr(10)+ ;
           "sudo mkdir /usr/share/help/fr/hwmake 2>/dev/null"+chr(10)+ ;
           "sudo cp * /usr/share/help/"+left(clanguage,2)+"/hwmake"+chr(10)+ ;
           'echo ""'+chr(10)+ ;
           "echo -e ${gGre}"+_("Press a key to continue ...")+"${nocolor}"+chr(10)+ ;
           "read"+chr(10)
      hb_memowrit("../instyelp",ctxt)
      hb_run("sh -c 'chmod +x ../instyelp'")
      hb_run(cterminal+" -x "+cspath+"/Documentation/yelp/instyelp")
   endif
3 Attachments

Discussion

  • Wilfried Brunken

    Hello Alain,
    i have done some little modifications:
    - Added comments in english (translation from french)
    - Added header and $Id$ for SVN identification
    - Shell script has now file extension ".sh".
    - Information, that this feature is "LINUX only",
    because the QOUT outputs are supressed by the WinAPI,
    if running a graphical application.
    On the GTK cross development environment the
    messages of the GTK system on the command windows
    is also not visible.
    So sample program placed in samples/gtk_samples.
    - Added a screenshot in
    samples/gtk_samples/image/qoutcolor.prg_output.png

    Committed with r2928.
    The .ch file is now in directory "include", so it can be found
    in the standard include path.

    Tested on my UBUNTU 16.04 LTS system.

    I hope, that is OK for you.
    Please give feedback.

    MNI TNX fer ur support.

    With regards,
    73 es 55 de
    DF7BE, Wilfried

     
  • Aupeix Alain

    Aupeix Alain - 2021-01-14

    Hi Wilfried,

    Thanks for adding it, it works well

    Just a remark, something is wrong in the header:

    # Header file to allow colors in qout()
    Call specification:
    # . ./colors.sh

    # Script file to allow colors in scripts created by harbour/hwgui
    To use instead of constants of qcolor one
    The names are identical, but it doesn't work if you use qcolor constants in script.

    In the sample I gave for script, It would be wrong :

    ctxt="#!/bin/bash"+chr(10)+chr(10)+ ;
                 "echo -e "+gCya+"Installing the yelp help of" + ;          
                 gGre+"hwmake"+noColor+chr(10)+ ;
               'echo ""'+chr(10)+ ;
               "sudo mkdir /usr/share/help/fr/hwmake 2>/dev/null"+chr(10)+ ;
               "sudo cp * /usr/share/help/"+left(clanguage,2)+"/hwmake"+chr(10)+ ;
               'echo ""'+chr(10)+ ;
               "echo -e "+gGre+_("Press a key to continue ...")+"nocolor+chr(10)+ ;
               "read"+chr(10)
    hb_memowrit("../instyelp",ctxt)
    hb_run("sh -c 'chmod +x ../instyelp'")
    hb_run(cterminal+" -x "+cspath+"/Documentation/yelp/instyelp")
    

    it is right :

    ctxt="#!/bin/bash"+chr(10)+chr(10)+ ;
               "echo -e ${gCya}"+_("Installing the yelp help of") +; 
               "${gGre}hwmake${noColor}"+chr(10)+ ;
               'echo ""'+chr(10)+ ;
               "sudo mkdir /usr/share/help/fr/hwmake 2>/dev/null"+chr(10)+ ;
               "sudo cp * /usr/share/help/"+left(clanguage,2)+"/hwmake"+chr(10)+ ;
               'echo ""'+chr(10)+ ;
               "echo -e ${gGre}"+_("Press a key to continue...")+"${nocolor}"+chr(10)+ ;
               "read"+chr(10)
    hb_memowrit("../instyelp",ctxt)
    hb_run("sh -c 'chmod +x ../instyelp'")
    hb_run(cterminal+" -x "+cspath+"/Documentation/yelp/instyelp")
    

    I think it's important to insert hints in each concerned file, and perhaps a more simple sample in colors.sh
    The script can give advantage if located in the path, to avoid inserting . colors.sh in each script, and if located in .profile, variables are already available ... for all the scripts.

    A+

     

    Last edit: Aupeix Alain 2021-01-14
  • Wilfried Brunken

    Hello Alain,
    tested and committed with r 2930.

    Please check and give feedback.
    TNX fer ur support.

    With regards,
    73 es 55 de
    DF7BE, Wilfried

     
  • Aupeix Alain

    Aupeix Alain - 2021-01-17

    That's ok

    Thanks
    A+

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.