Improving the work with ANSI in various versions of Puppy

A home for all kinds of Puppy related projects

Moderator: Forum moderators

Post Reply
User avatar
Grey
Posts: 1984
Joined: Wed Jul 22, 2020 12:33 am
Location: Russia
Has thanked: 75 times
Been thanked: 355 times

Improving the work with ANSI in various versions of Puppy

Post by Grey »

@666philb , @dimkr , @jamesbond , @peebee , @fredx181 , @BarryK
(sorry if I forgot someone or bothered someone too much :) )
I have a suggestion for all developers and assemblers of different versions of Puppy.

Add such a wonderful thing as ANSI Code Generator to your future projects (if not added yet).

This wonderful bash script is not only fun, but also useful.

I put it in /root/my-applications/bin/ and now I can do various useful things and even such perversions :) :

Code: Select all

#!/bin/bash

showLine() {
    local I LEN REPLACED
    LEN="${#1}"
    REPLACED=""
    ansi -n --column=$((CENTER - ((LEN + 1) / 2)))
    for ((I=0; I < ${#1}; I++)); do
        case "${1:$I:1}" in
            "&")
                REPLACED+="$Cyan "
                ;;

            "R")
                REPLACED+="$Red "
                ;;

            "#")
                REPLACED+="$Y*"
                ;;

            "|")
                REPLACED+="$G|"
                ;;

            *)
                REPLACED+="$R?"
                ;;
        esac
    done
    echo "$REPLACED$R"
}

# Yellow
Y=$(ansi --bg-yellow --magenta --no-restore)
# Green
G=$(ansi --bg-black --green --no-restore)
# Red
Red=$(ansi --bg-red --no-restore)
# Cyan
Cyan=$(ansi --bg-cyan --no-restore)
# Reset
R=$(ansi --reset-color)

PUP=(
""
"R###&||##||##|R###R||R###R||R#||#R"
"##||##|##||##|##||##|##||##|##||##"
"R###&||RR||RR|R###R||R###R|||&##&|"
"##|||||##||##|##|||||##|||||||##||"
"R&||||||#R&#||R&|||||R&|||||||##||"
)

CENTER=$(tput cols)
CENTER=$((CENTER / 2))

ansi -n --save-cursor --hide-cursor --position=2,1

for LINE in "${PUP[@]}"; do
    showLine "$LINE"
done

ansi -n --cup=7,23 "          ___"
ansi -n --cup=8,23 "      /--| * | "
ansi -n --cup=9,23 "      \-| __| \ "
ansi -n --cup=10,23 "        |______|       |"
ansi -n --cup=11,23 "  ______||---|||       | "
ansi -n --cup=12,23 "|-|------|   |||       \__ "
ansi -n --cup=13,23 "|_|      ____|||     ___ _ _ "
ansi -n --cup=14,23 "|_|_____|------|     [ ]  | "
ansi -n --cup=15,23 "  |____|  \  |_______] | _|_ "
ansi -n --cup=16,23 "          |      (--)  | "
ansi -n --cup=17,23 "          |      {__} _| |\ | "
ansi -n --cup=18,23 "          |  /----\  /   | \| "
ansi -n --cup=19,23 "          | |     || |       | | "
ansi -n --cup=20,23 "          | |     || |       \_/ " 
ansi -n --cup=21,23 "          | |     || |          \/ "
ansi -n --cup=22,23 "          |_|      \_|          /\ "

ansi --title=PuppyLinux -n --show-cursor --restore-cursor

An old friend of mine said today that Puppy here does not look like a Robopup, but looks like... a miner in a coal mine :) Mmmm... Okay, there's something to it (helmet?!) :) Result:

puplinux_ansi.gif
puplinux_ansi.gif (55.68 KiB) Viewed 1213 times

Fossapup OS, Ryzen 5 3600 CPU, 64 GB RAM, GeForce GTX 1050 Ti 4 GB, Sound Blaster Audigy Rx with amplifier + Yamaha speakers for loud sound, USB Sound Blaster X-Fi Surround 5.1 Pro V3 + headphones for quiet sound.

user1111

Re: Improving the work with ANSI in various versions of Puppy

Post by user1111 »

My first perception of that image was of Puppy dog shit .. at least until my eyes took in the LINUX text.

User avatar
Grey
Posts: 1984
Joined: Wed Jul 22, 2020 12:33 am
Location: Russia
Has thanked: 75 times
Been thanked: 355 times

Re: Improving the work with ANSI in various versions of Puppy

Post by Grey »

My first perception of that image was of Puppy dog shit .. at least until my eyes took in the LINUX text.

I looked more closely. If I look fast...

It may need to be changed to something unambiguous. Otherwise, users of other systems will think that we (or I) are not respectable people and not even cultured :) But now I'm too lazy to even finish drawing a bone on wheels near Puppy (something like a miner's trolley) :)

Fossapup OS, Ryzen 5 3600 CPU, 64 GB RAM, GeForce GTX 1050 Ti 4 GB, Sound Blaster Audigy Rx with amplifier + Yamaha speakers for loud sound, USB Sound Blaster X-Fi Surround 5.1 Pro V3 + headphones for quiet sound.

Post Reply

Return to “Puppy Projects”