From 8d8ada7ba3b84601da891cf92464fab9fccc5b2b Mon Sep 17 00:00:00 2001 From: Trent Huber Date: Fri, 18 Apr 2025 23:45:49 -0400 Subject: [PATCH] Update `README.md' --- README.md | 18 +++++++++++++----- build.h | 2 +- clean.c | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 09045e7..20cdd73 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # simplexpm -simplexpm is a simple GUI application used to view XPM image files. The entire application is written in C, even down to the build system. +simplexpm is a simple GUI application used to view XPM image files. ## Building @@ -23,12 +23,20 @@ Running the `build` executable we just generated will build the entire project. $ ./build ``` -Once built, the application will be located in the `bin/` folder. It should be noted that once the application is created it can be moved/copied around the file system as the binary itself has all its assets baked in and doesn't depend on anything in the repository once built. +Once built, the application will be located in the `bin/` folder. ```console $ ./bin/simplexpm ``` +To clean the repository after building, just run the `clean` executable generated by the build system. + +```console +$ ./clean +``` + +The `clean` executable doesn't remove the root `build` executable, so you can always rebuild the project without having to bootstrap again. + ## Usage Files can either be provided at the command line with the `-f` flag or dragged into the application once it's opened. Once content is loaded, the window can be resized and the content will scale accordingly. @@ -42,10 +50,10 @@ Finally, with an XPM file loaded, color modes can be changed by pressing corresp ```console $ ./bin/simplexpm -f images/test.xpm ``` -![Here's an image of the application running on my machine.](images/application.png "A simplexpm window") +![Here's an image of the above command running on my machine.](images/application.png "Running the above command") ## Theory of Operation -Since valid XPM files are necessarily valid C source code, the most straightforward way to process the data is to just compile the file. Integrating that into an interactive application involves the use of dynamic libraries-luckily that's nothing cbs can't handle. +Since valid XPM files are necessarily valid C source code, the most straightforward way to process the data is to just compile the file and access the pixel data directly. Integrating that into an interactive application however involves the use of dynamic libraries loading that data at runtime. -The first phase of the application is to get the path name of the XPM file from the user. Once that's done, we copy the file to a temporary file, compile and link that file to a dynamic library, and then open and load the symbols from the file *all during the runtime of the application* (this process can be seen if you enable running with debug information via the `-d` flag). These symbols have all the data we need to display the image without having to parse almost any of the file itself (we do a bit of parsing to know what symbol name to call, but that's about it). Of course, we still have to parse the actual data stored in the string array, but that's very straightforward since the core standard is relatively simple (I used chapter 2 of [this manual](https://www.xfree86.org/4.8.0/xpm.pdf) as reference). +The first phase of the application is to get the path name of the XPM file from the user. Once that's done, we copy the file to a temporary file, compile and link that file to a dynamic library, and then open and load the symbols from that dynamic library-all while the application is running. These symbols have all the data we need to display the image without having to parse almost any of the file itself (we do a bit of parsing to know what symbol name to call, but that's about it). Of course, we still have to parse the actual data stored in the string array, but that's very straightforward since the core standard is relatively simple (I used chapter 2 of [this manual](https://www.xfree86.org/4.8.0/xpm.pdf) as reference). Once the pixel data is parsed, a [Raylib](https://github.com/raysan5/raylib) texture is generated from it and displayed in the window. diff --git a/build.h b/build.h index dfcf343..1a61d10 100644 --- a/build.h +++ b/build.h @@ -1,5 +1,5 @@ /* Switch the following #define to change whether or not raylib is built as a - * static or dynamic library; be sure to `./clean' before you `./build' again. + * static or dynamic library; be sure to `clean' before you `build' again. */ // #define RLDYNAMIC diff --git a/clean.c b/clean.c index cddf955..1cce666 100644 --- a/clean.c +++ b/clean.c @@ -38,7 +38,7 @@ int main(void) { (char *[3]){COLORS, FONT}, (char *[3]){whos[3]}}; for (i = 0; i < 4; ++i) { if ((cpid = fork()) == 0) - run(RM, (char *[]){"rm", rms[i][0], rms[i][1], rms[i][2], NULL}, + run(RM, (char *[]){"rm", "-f", rms[i][0], rms[i][1], rms[i][2], NULL}, what, whos[i]); await(cpid, what, whos[i]); } -- 2.51.0