Debian Codegraph @

doc/HACKING

raw
1 "There's a difference between knowing the path... and walking the path."
2 -Morpheus
3
4 neo is a program written in C++ that uses the ncursesw library to control
5 the terminal. It is built using autotools.
6
7 The code is split mostly into three files:
8
9 neo.cpp - Handles the main loop, command-line options, and initializing ncurses.
10 cloud.cpp - Implements the Cloud class, which manages all the Droplets.
11 droplet.cpp - Implements the Droplet class, which moves/draws the characters.
12
13 The application's main loop creates a single Cloud object that manages all
14 the Droplets. Each Droplet is responsible for moving and drawing a vertical
15 string of characters. Cloud and Droplet are tightly coupled. It is expected
16 that Cloud should call into each Droplet's methods, but several Droplet
17 methods call back into Cloud. This is one possible area for improvement.
18 Cloud also keeps track of the color and glitch status for each character on
19 screen.
20
21 neo makes heavy use of the "pool" idiom, which is more commonly seen in game
22 development. Rather than allocating objects on the fly, neo allocates many
23 objects, disabling and reusing them as needed. For example, neo allocates as
24 many Droplets as it needs whenever Cloud is reset. neo also uses a pool for the
25 characters that are drawn to the screen. Each Droplet has an index into this
26 pool of random characters.
27
28 neo does a few other tricks to improve performance. The main one is that it
29 tries to draw as few characters as possible per frame rather than drawing
30 every character onscreen. To do this, each Droplet keeps track of a "CurLine"
31 position and a "PutLine". CurLine indicates the last line that was drawn on
32 the last frame. PutLine indicates the last line that must be drawn this frame.
33
34 The code is not idiomatic modern C++. There are many uses of older C functions
35 such as fprintf(), strtok(), etc. In general, the style is a hodge-podge of
36 C++11 with older C idioms and a liberal use of cstdint types with an avoidance
37 of lambdas, streams, templates, and overusing the "auto" keyword. The code
38 makes some use of the newer C++11 chrono and random libraries. K&R C bracing
39 is the norm, as are soft tabs.
40
41 If you submit a pull request, please avoid adding additional dependencies
42 and make sure any relevant documentation has also been added or updated.
43
44 Ideas for contribution:
45
46 - Fix any open issue on GitHub
47 - Refactor Cloud to better follow SOLID OOP principles
48 - Make Cloud a proper singleton
49 - Use one mt19937 object per distribution for better independence
50 - Add more parameters to --charset (e.g. Chinese)
51 - Performance improvements