U bekijkt momenteel de Netherlands versie van de site.
Wilt u overschakelen naar uw lokale site?
14 MIN LEESTIJD

LXF SHELL

Snaky shell: adding fun Easter eggs

Tired and relieved, Ferenc Deák breaks open a few delicious Easter eggs to celebrate the end of a shell coding era!

OUR EXPERT

Ferenc Deák already has plans to bend your brains with future code – write in if you want him to stop!

QUICK TIP

Discover the full project and much more at its GitHub site: https://github. com/fritzone/lxf-shell

Welcome to the final part of our series on building a Linux shell from the ground up. Throughout the previous seven instalments, we’ve walked through the entire process of designing and developing a custom shell, starting with the basic foundations of input/output handling, command parsing and job control. We have gone through several layers of more and more complex code and Linux functionality from a programmer’s point of view, but this time, we’ve decided to make something different. We’re showing you how to create a simple game that can be hidden as an Easter egg within your shell. By the end of this tutorial, you’ll have a fully functional shell complete with a hidden game, giving your project both utility and a dash of personality. In order to give a more game-like feel to our game, we’re using the closest the terminal can get to presenting graphics as per 2024: the ncurses library.

Don’t curse us

The curses library originated at the University of California, Berkeley, in the late 1970s as part of the BSD Unix operating system. It was designed to provide a high-level interface for controlling text-based terminal displays, allowing developers to create interactive, screen-oriented applications. In the 1980s, System V Unix incorporated a variant of curses, and in 1993, ncurses (new curses) was created as an open source, more portable alternative, expanding its features across various Unix-like systems.

Over time, ncurses became widely adopted, with added support for modern terminal features, such as colours, wide characters and mouse handling. One of the most famous showcases of the ncurses library is to be found in Midnight Commander, which we’ve featured in several issues of Linux Format (most recently LXF280)

The most important features of ncurses include: Screen handling: It manages the content displayed in a terminal, making it easy to draw windows, update parts of the screen, and handle complex layouts.

Input handling: It allows for robust input handling from the keyboard and mouse, managing special key events, and detecting key combinations.

Character display: It manages character output, enabling the display of coloured and stylised text.

Multiple windows: You can define multiple areas or windows within the terminal screen.

Portability: It abstracts features, allowing the code to run across various terminal emulators and systems.

Ontgrendel dit artikel en nog veel meer met
Je kunt genieten:
Geniet volledig van deze editie
Direct toegang tot 600+ titels
Duizenden oude edities
Geen contract of verplichting
ABONNEER NU
30 dagen proberen, dan gewoon €11,99 / maand. Op elk moment opzeggen. Alleen nieuwe abonnees.


Meer informatie
Pocketmags Plus
Pocketmags Plus

Dit artikel komt uit...


View Issues
Linux Format
January 2025
IN DE WINKEL BEKIJKEN

Andere artikelen in dit nummer


LINUX FORMAT
LINUX FORMAT
The #1 open source mag Future Publishing Limited,
WELCOME
MEET THE TEAM
We’re pondering whether new users are coming to Linux with the Steam Deck and using the Pi. What got you hooked using Linux in the first place?
Easy as 1, 2, 3.14!
There’s been a bit of chatter recently about
REGULARS AT A GLANCE
Mozilla Foundation cuts staff as Firefox turns 20
As Firefox celebrates its 20th anniversary, Mozilla follows the tech industry’s current downsizing trend by laying off 30% of its employees.
Huge boost for RADV driver
A Valve engineer’s fix for AMD FSR2 in the Mesa RADV driver has significantly improved performance.
Intel patch for outdated microcode?
Outdated CPU microcode would be classed as a security vulnerability.
VIDEO STARS
Italo Vignoli is one of the founders of LibreOffice and the Document Foundation.
THE RIGHT TRACK?
Dave Stokes is a technology evangelist at Percona.
RISC-V coming to Framework laptops
RISC-V mainboard brings open-source architecture to laptops and desktops.
Apple Maps works in Linux
The beta web version will run – but only in Firefox.
LXQt 2.1.0 released
The latest version improves both system performance and Wayland support.
Distro watch
What’s behind the free software sofa?
FREE DESKTOPS!
Mark Filion is a senior marketing manager at Collabora.
THE RUST SETTLES
Jon Masters is a kernel hacker who’s been involved with Linux for over 22 years, and works on energy-efficient Arm servers.
Kernel Watch
Jon Masters summarises the latest happenings in the Linux kernel, so that you don’t have to.
Answers
Got a burning question about open source or the kernel? Whatever your level, email it to answers@linuxformat.com
Mailserver
WRITE TO US Do you have a burning
HotPicks
THE BEST NEW OPEN SOURCE SOFTWARE ON THE PLANET
GET INSIDE OPEN AI!
We peel open AI to reveal the soft, squishy machine-learning innards, how it works and how to use it!
REVIEWS
Intel Core Ultra 9 285K
Paul Alcorn sees what Intel has built with its new chiplet architecture.
Ubuntu Studio 24.10
Nate Drake tentatively turns the knobs and dials of Ubuntu Studio. Is this the definitive Linux distro for media moguls?
FunOS 24.04.1
Nate Drake shares the delights of this Ubuntu-based distro, using the lightweight JWM. Does anyone else think it should be called Funbuntu?
Ubuntu Unity 24.10
Nate Drake invites you to explore a distro that relives the glory days of Ubuntu by deploying the Unity interface.
LastOSLinux 2024.10
Nate Drake delves into LastOS. Is this the last word in Windows-friendly distros or the last thing you’d want to install?
Shogun Showdown
It seems The Management has barricaded itself into its gold-plated top-floor office now Robin Valentine is a fully qualified shogun.
ROUNDUP
Roundup
IntelliJ IDEA KDevelop Geany Apache NetBeans Visual Studio Code
ESSENTIAL RASPBERRY PI MAKES
Essential Raspberry Pi makes
Grab your Pi, grab your soldering iron and get making with our quick-start guide to Pi fun with Les Pounder and Nate Drake as your little helpers.
Pi USER
First public view of Pi Compute Module 5
German electronics fair gets a first glimpse of the fruity new single-board computer.
Ubuntu 24.10
Les Pounder has been using Ubuntu for nearly 20 years, but could this anniversary edition change his mind about running it on the Pi?
AI Camera
On his quest to bring AI to the masses, Les Pounder manages to put them all out of work.
Bringing Arduino IDE coding to the Pi Pico
Les Pounder loves a blinking LED – it probably take him back to the flashing clock on his old VCR he could never reset… ARDUINO Credit: www.arduino.cc
TUTORIALS
Saving private files
Credit: https://github.com/MilesCranmer/rip2
Collect, organise and archive web pages
Credit: https://linkwarden.app
OpenStreetMap: map or be mapped
Credit: www.openstreetmap.org
Experience the EDSAC
Credit: www.dcs.warwick.ac.uk/~edsac
Using your Steam Deck as a full desktop PC
Always game for anything, Christian Cawley shows you that while the Steam Deck is great for gaming, it can do so much more.
Start photo editing with the new GIMP 3.0
After two decades of waiting, GIMP has finally been updated to version 3.0. Neil Mohr is on hand to get you up to speed.
ADMINISTERIA
Stay alert with system email warnings!
Never one to like unexpected surprises – or missing his wife’s birthday – Stuart Burns ensures his servers are bristling with email alerts.
ACT LIKE THERE IS NO TOMORROW
Stuart Burns is a sysadmin for a
Duda
Built with agencies in mind, Ruby P Jane tests this comprehensive web builder to determine whether it’s a dud or a dude.
IN DEPTH
Fyne times ahead
So, you want a cross-platform app that can be deployed on mobile, desktop and the web, do you? Andrew Williams might have a toolkit that can make your life a little easier…
CODING ACADEMY
Discover and extend the Pragtical editor
Ever-practical David Bolton demonstrates how to write a plugin for the open source editor Pragtical in the Lua language.
Chat
X
Pocketmags ondersteuning