This C program creates animations of the Split Buffer. It is inspired by and adapted from skeeto/gap-buffer-animator. A split buffer (unofficial name) is a variation of the gap buffer. This blog post provides further information about this data structure.
To run the commands in the Makefile, ensure you have convert, gifsicle, and ppmtoy4m in your machine.
Ubuntu should already come with convert. Simply run these commands:
$ sudo apt-get gifsicle
$ sudo apt-get ppmtoy4mmacOS does not come with a built-in convert. The convert utility comes with imagemagick. Homebrew also cannot resolve the ppmtoy4m package.
$ brew install imagemagick
$ brew install gifsicleNote for macOS: You may need to change the compiler in the Makefile from c99 to something else, such as gcc. Currently, there is also a bug where the .gif generated in macOS off-by-one for the waiting frames. More specifically, every calls to wait will start one frame earlier, prematurely pausing any series of inserts. Edit: apparently this is a bug with the macOS preview. Uploaded GIFs will be correctly played.
The Makefile specifies the recipe to create the .gif animations.
- Creating the
.giffile:
$ make gif- Viewing the
.giffile without saving them (Not available in macOS):
$ make viewTo view the .gif, currently there is no choice but to preview them on macOS. To do so, select the .gif in finder and press spacebar, or press Command + Y.
- Cleaning up generated files
$ make cleanTo create your own animation, you can rewrite the contents of the intro[] array in main method of splitbuf-anim.c with the actions that you want. The opcode enum specifies what actions can be taken. More examples can be found in gapbuf.c, which is the original file that this project is adapted from.
An intro[] array is an array of command, which has an opcode attached to it and an arg.
Important: The num_horiz_chars variable inside splitbuf_draw should be updated to the number maximum total size of the buffer at any point of time of your own text. A helper code in the program has been written that will print this value to the stdout.
This subsection provides some explanation of the Opcodes
C_HALT: The opcode for the command at the end of the animation.C_WAIT: The opcode to wait..arg.vtakes in anintwhich representes the duration of the waiting. The default is 10 = 1 second.C_FORWARD: The opcode to move forward..arg.vtakes in anintwhich represents how many characters forward to move.C_BACKWARD: The opcode to move backward..arg.vtakes in an posstiveintwhich represents how many characters backward to move.C_QMOVE: The opcode to quietly move. The cursor will jump according to theintspecified in.arg.v. Can take in negative values as well.C_INSERT: The opcode for inserting a character. The.arg.vvalue takes in acharto be inserted.C_QINSERT: The opcode to quietly insert character. The.arg.vvalue takes in acharto be inserted.C_STRING: The opcode to append a string to where the cursor is. The.arg.svalue takes in the string to be appended.C_QSTRING: The opcode to quietly append a string to where the cursor is. The.arg.svalue takes in the string to be appended.C_DELETE: The opcode to delete the character after the cursor. The.arg.vvalue takes anintrepresenting the number of characters to be deleted.C_BACKSPACE: The opcode to delete the character before the cursor. The.arg.vvalue takes anintrepresenting the number of characters to be deleted.
