Giter VIP home page Giter VIP logo

antterminal's Introduction

antTerminal

Simple terminal implementation with a demo shell on top of it.

It is quite simple: implements basic character handling, left/right arrow movement in the current line, blocking at the EOL limit, deleting characters, inserting characters and a blueprint for the implementation of CTRL characters/sequences. These are used by the demo shell which implements a command line parsing and command execution example. Based on this implementation, project can be expanded in various different ways.

I got the idea to write this implementation in my other projects where I had to use a shell like approach for communication between different components, such as a container and a host over a unix socket rather than STDOUT.

Basic remarks

Terminal code is contained in terminal.c and terminal.h at src location. These provide basic operations for character handling and terminal setup. The shell.c and shell.h provide a simple implentation of shell parser. As it can be noticed, terminal is accessed directly by calling the terminal functions such as void terminal_putstring(char *c) directly but in pratice, these function should be wrapped around with a "library" like functions such as printf.

Building and testing

To build a project, cerate a build directory in the root project directory and cd into it:

mkdir build
cd build

Invoke cmake from there flowed by make:

cmake ..
make

The binary can then be started from the same location:

./antTerminal

Once in the shell, four demo commands are supported: ls, cd, pwd and exit. They do nothing at all and just serve as a demo commands for testing the basic behavior of the shell and the terminal. Max number of arguments passed to any of these is four (five with the command) and passing more then four args will cut them off on four.

To test, run:

term > ls arg1 arg2 arg3 arg4

Passing an unregistered command will trigger unknown command response. Current max line length is set by default to 80 characters. Try printing out a character 80 times and navigate with arrows over the line and delete/modify the characters to test the behavior.

For exit, type exit or press CTRL+q which will exit, clear and reset the terminal back to the original terminal.

antterminal's People

Contributors

popovicd avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.