Browse Source

Application cleanup

K. Lange 2 years ago
parent
commit
b6c3951497
50 changed files with 554 additions and 367 deletions
  1. 2 1
      apps/beep.c
  2. 8 6
      apps/bim.c
  3. 4 4
      apps/cat.c
  4. 8 8
      apps/clear.c
  5. 262 6
      apps/compositor.c
  6. 8 4
      apps/cp.c
  7. 10 2
      apps/drawlines.c
  8. 27 23
      apps/echo.c
  9. 14 14
      apps/env.c
  10. 2 2
      apps/fetch.c
  11. 15 12
      apps/fgrep.c
  12. 1 1
      apps/hostname.c
  13. 1 1
      apps/init.c
  14. 5 1
      apps/insmod.c
  15. 5 6
      apps/irc.c
  16. 2 2
      apps/julia.c
  17. 4 1
      apps/kdebug.c
  18. 6 5
      apps/kill.c
  19. 2 2
      apps/killall.c
  20. 9 0
      apps/login-loop.c
  21. 9 2
      apps/menu.c
  22. 1 1
      apps/nslookup.c
  23. 1 1
      apps/nyancat.c
  24. 4 1
      apps/piano.c
  25. 2 5
      apps/pidof.c
  26. 2 3
      apps/plasma.c
  27. 7 1
      apps/play.c
  28. 3 2
      apps/pong.c
  29. 4 7
      apps/pstree.c
  30. 3 2
      apps/pwd.c
  31. 8 2
      apps/readelf.c
  32. 4 5
      apps/reboot.c
  33. 3 5
      apps/rm.c
  34. 3 2
      apps/sdf-demo.c
  35. 4 9
      apps/sleep.c
  36. 2 3
      apps/sysfunc.c
  37. 8 1
      apps/term-size.c
  38. BIN
      apps/terminal-font.h
  39. 10 2
      apps/terminal-palette.h
  40. 10 1
      apps/toaru_logo.h
  41. 11 0
      apps/toggle-abs-mouse.c
  42. 3 4
      apps/touch.c
  43. 7 0
      apps/true.c
  44. 15 0
      apps/ttysize.c
  45. 9 5
      apps/uname.c
  46. 13 0
      apps/vga-palette.h
  47. 7 4
      apps/which.c
  48. 3 4
      apps/yes.c
  49. 3 2
      apps/yutani-test.c
  50. 0 192
      apps/yutani_int.h

+ 2 - 1
apps/beep.c

@@ -1,4 +1,5 @@
-/* This file is part of ToaruOS and is released under the terms
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2014 K. Lange
  */

+ 8 - 6
apps/bim.c

@@ -1,16 +1,18 @@
-/* vim: ts=4 sw=4 noexpandtab
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
  * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2013-2018 K. Lange
  * Copyright (C) 2014 Lioncash
- */
-/*
- * bim
  *
- * Bim is a Bad IMitation of Vim.
+ * bim - Text editor
  *
- * The 'standard' text editor for とあるOS.
+ * bim is a "Bad IMitation" of vim. This is the standard text
+ * editor fo ToaruOS. It provides basic editing capabilities.
  *
+ * Expansion of bim is planned. I'd love to see it one day have
+ * syntax hilighting, for example. It's also painfully slow,
+ * so speed improvement is a must - most probably by not
+ * redrawing the entire screen all the time.
  */
 #define _XOPEN_SOURCE 1
 #include <stdio.h>

+ 4 - 4
apps/cat.c

@@ -1,9 +1,9 @@
-/* This file is part of ToaruOS and is released under the terms
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2013-2018 K. Lange
- */
-/*
- * cat
+ *
+ * cat - Concatenate files
  *
  * Concatenates files together to standard output.
  * In a supporting terminal, you can then pipe

+ 8 - 8
apps/clear.c

@@ -1,14 +1,14 @@
-/* This file is part of ToaruOS and is released under the terms
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2013 K. Lange
- */
-/*
- * clear
  *
- * Clears the terminal.
- * This is a very dumb version and probably only works
- * within the toaruOS terminal, but it might also work
- * with an xterm or similar.
+ * clear - Clear the terminal
+ *
+ * Sends an escape code to clear the screen. Ideally, this should
+ * come from a database of terminal escape codes (eg. terminfo),
+ * but we don't have one of those yet, so just send a code that
+ * makes sense for a lot of terminals.
  */
 #include <stdio.h>
 

+ 262 - 6
apps/compositor.c

@@ -50,18 +50,55 @@
 #define TRACE(msg,...)
 #endif
 
-#include "yutani_int.h"
-
-#define YUTANI_DEBUG_WINDOW_BOUNDS 1
-#define YUTANI_DEBUG_WINDOW_SHAPES 1
-#define YUTANI_RESIZE_RIGHT 0
+/* Mouse resolution scaling */
+#define MOUSE_SCALE 3
 #define YUTANI_INCOMING_MOUSE_SCALE * 3
 
+/* Mouse cursor hotspot */
+#define MOUSE_OFFSET_X 26
+#define MOUSE_OFFSET_Y 26
+
+/* Mouse cursor size */
 #define MOUSE_WIDTH 64
 #define MOUSE_HEIGHT 64
 
+/* How much the mouse needs to move to break off a tiled window */
 #define UNTILE_SENSITIVITY (MOUSE_SCALE * 5)
 
+/* Screenshot modes */
+#define YUTANI_SCREENSHOT_FULL 1
+#define YUTANI_SCREENSHOT_WINDOW 2
+
+/*
+ * Animation effect types.
+ * XXX: Should this be in the client library?
+ */
+typedef enum {
+	YUTANI_EFFECT_NONE,
+
+	/* Basic animations */
+	YUTANI_EFFECT_FADE_IN,
+	YUTANI_EFFECT_FADE_OUT,
+
+	/* XXX: Are these used? */
+	YUTANI_EFFECT_MINIMIZE,
+	YUTANI_EFFECT_UNMINIMIZE,
+} yutani_effect;
+
+/* Animation lengths */
+static int yutani_animation_lengths[] = {
+	0,   /* None */
+	200, /* Fade In */
+	200, /* Fade Out */
+	0,   /* Minimize */
+	0,   /* Unminimized */
+};
+
+/* Debug Options */
+#define YUTANI_DEBUG_WINDOW_BOUNDS 1
+#define YUTANI_DEBUG_WINDOW_SHAPES 1
+
+/* Command line flag values */
 struct {
 	int nested;
 	int nest_width;
@@ -72,6 +109,226 @@ struct {
 	.nest_height = 480,
 };
 
+/*
+ * Server window definitions
+ */
+typedef struct YutaniServerWindow {
+	/* Window identifier number */
+	yutani_wid_t wid;
+
+	/* Window location */
+	signed long x;
+	signed long y;
+
+	/* Stack order */
+	unsigned short z;
+
+	/* Window size */
+	int32_t width;
+	int32_t height;
+
+	/* Canvas buffer */
+	uint8_t * buffer;
+	uint32_t bufid;
+	uint32_t newbufid;
+	uint8_t * newbuffer;
+
+	/* Connection that owns this window */
+	uint32_t owner;
+
+	/* Rotation of windows XXX */
+	int16_t  rotation;
+
+	/* Client advertisements */
+	uint32_t client_flags;
+	uint16_t client_offsets[5];
+	uint32_t client_length;
+	char *   client_strings;
+
+	/* Window animations */
+	int anim_mode;
+	uint32_t anim_start;
+
+	/* Alpha shaping threshold */
+	int alpha_threshold;
+
+	/*
+	 * Mouse cursor selection
+	 * Originally, this specified whether the mouse was
+	 * hidden, but it plays double duty since client
+	 * control over mouse cursors was added.
+	 */
+	int show_mouse;
+	int default_mouse;
+
+	/* Tiling / untiling information */
+	int tiled;
+	int32_t untiled_width;
+	int32_t untiled_height;
+	int32_t untiled_left;
+	int32_t untiled_top;
+
+	/* Client-configurable server behavior flags */
+	uint32_t server_flags;
+
+	/* Window opacity */
+	int opacity;
+} yutani_server_window_t;
+
+typedef struct YutaniGlobals {
+	/* Display resolution */
+	unsigned int width;
+	unsigned int height;
+	uint32_t stride;
+
+	/* TODO: What about multiple screens?
+	 *
+	 * Obviously this is the whole canvas size,
+	 * but we need to be able to track different
+	 * monitors if/when we ever get support for that.
+	 */
+
+	/* Core graphics context */
+	void * backend_framebuffer;
+	gfx_context_t * backend_ctx;
+
+	/* Mouse location */
+	signed int mouse_x;
+	signed int mouse_y;
+
+	/*
+	 * Previous mouse location, so that events can have
+	 * both the new and old mouse location together
+	 */
+	signed int last_mouse_x;
+	signed int last_mouse_y;
+
+	/* List of all windows */
+	list_t * windows;
+
+	/* Hash of window IDs to their objects */
+	hashmap_t * wids_to_windows;
+
+	/*
+	 * Window stacking information
+	 * TODO: Support multiple top and bottom windows.
+	 */
+	yutani_server_window_t * bottom_z;
+	list_t * mid_zs;
+	yutani_server_window_t * top_z;
+
+	/* Damage region list */
+	list_t * update_list;
+	volatile int update_list_lock;
+
+	/* Mouse cursors */
+	sprite_t mouse_sprite;
+	sprite_t mouse_sprite_drag;
+	sprite_t mouse_sprite_resize_v;
+	sprite_t mouse_sprite_resize_h;
+	sprite_t mouse_sprite_resize_da;
+	sprite_t mouse_sprite_resize_db;
+	int current_cursor;
+
+	/* Server backend communication identifier */
+	char * server_ident;
+	FILE * server;
+
+	/* Pointer to focused window */
+	yutani_server_window_t * focused_window;
+
+	/* Mouse movement state */
+	int mouse_state;
+
+	/* Pointer to window being manipulated by mouse actions */
+	yutani_server_window_t * mouse_window;
+
+	/* Buffered information on mouse-moved window */
+	int mouse_win_x;
+	int mouse_win_y;
+	int mouse_init_x;
+	int mouse_init_y;
+	int mouse_init_r;
+
+	int32_t mouse_click_x_orig;
+	int32_t mouse_click_y_orig;
+
+	int mouse_drag_button;
+	int mouse_moved;
+
+	int32_t mouse_click_x;
+	int32_t mouse_click_y;
+
+	/* Keyboard library state machine state */
+	key_event_state_t kbd_state;
+
+	/* Pointer to window being resized */
+	yutani_server_window_t * resizing_window;
+	int32_t resizing_w;
+	int32_t resizing_h;
+	yutani_scale_direction_t resizing_direction;
+	int32_t resizing_offset_x;
+	int32_t resizing_offset_y;
+	int resizing_button;
+
+	/* List of clients subscribing to window information events */
+	list_t * window_subscribers;
+
+	/* When the server started, used for timing functions */
+	time_t start_time;
+	suseconds_t start_subtime;
+
+	/* Basic lock to prevent redraw thread and communication thread interference */
+	volatile int redraw_lock;
+
+	/* Pointer to last hovered window to allow exit events */
+	yutani_server_window_t * old_hover_window;
+
+	/* Key bindigns */
+	hashmap_t * key_binds;
+
+	/* Windows to remove after the end of the rendering pass */
+	list_t * windows_to_remove;
+
+	/* For nested mode, the host Yutani context and window */
+	yutani_t * host_context;
+	yutani_window_t * host_window;
+
+	/* Map of clients to their windows */
+	hashmap_t * clients_to_windows;
+
+	/* Toggles for debugging window locations */
+	int debug_bounds;
+	int debug_shapes;
+
+	/* If the next rendered frame should be saved as a screenshot */
+	int screenshot_frame;
+
+	/* Next frame should resize host context */
+	int resize_on_next;
+
+	/* Last mouse buttons - used for some specialized mouse drivers */
+	uint32_t last_mouse_buttons;
+
+	/* Clipboard buffer */
+	char clipboard[512];
+	int clipboard_size;
+
+	/* VirtualBox Seamless mode support information */
+	int vbox_rects;
+	int vbox_pointer;
+} yutani_globals_t;
+
+struct key_bind {
+	unsigned int owner;
+	int response;
+};
+
+/* Early definitions */
+static void mark_window(yutani_globals_t * yg, yutani_server_window_t * window);
+static void window_actually_close(yutani_globals_t * yg, yutani_server_window_t * w);
+static void notify_subscribers(yutani_globals_t * yg);
+
 /**
  * Print usage information.
  */
@@ -1945,7 +2202,6 @@ int main(int argc, char * argv[]) {
 		/* XXX check if this already exists? */
 		yg->server_ident = "compositor";
 	}
-	// XXX need setenv to get display variable
 	setenv("DISPLAY", yg->server_ident, 1);
 
 	FILE * server = pex_bind(yg->server_ident);

+ 8 - 4
apps/cp.c

@@ -1,10 +1,14 @@
-/* This file is part of ToaruOS and is released under the terms
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2013 K. Lange
  * Copyright (C) 2013 Tyler Bindon
- */
-/*
- * cp
+ *
+ * cp - Copy files
+ *
+ * This is an incomplete implementation of `cp`. A more complete
+ * version of recursive directory copying can be found in the
+ * `migrate` sources, and should probably be imported here.
  */
 #include <stdlib.h>
 #include <string.h>

+ 10 - 2
apps/drawlines.c

@@ -1,10 +1,18 @@
-/* vim: ts=4 sw=4 noexpandtab
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
  * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2013-2018 K. Lange
  *
- * Yutani demo application that draws lines into a window.
+ * drawlines - Draw random lines into a GUI window
  *
+ * The original compositor demo application, this dates all the
+ * way back to the original pre-Yutani compositor. Opens a very
+ * basic window (no decorations) and randomly fills it with
+ * colorful lines in a separate thread from the listener.
+ *
+ * There's no good reason for this to use threads - it should use
+ * `fswait2` to apply timeouts - but it demonstrates threading
+ * so we'll leave it that way for now.
  */
 #include <stdlib.h>
 #include <assert.h>

+ 27 - 23
apps/echo.c

@@ -1,46 +1,50 @@
-/* This file is part of ToaruOS and is released under the terms
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2013-2018 K. Lange
- */
-/* vim: tabstop=4 shiftwidth=4 noexpandtab
  *
- * echo
+ * echo - Print arguments to stdout.
  *
- * Prints its arguments (with some processing, ask --help)
- * to standard out.
+ * Prints arguments to stdout, possibly interpreting escape
+ * sequences in the arguments.
  */
 #include <stdio.h>
 #include <string.h>
+#include <unistd.h>
 
-void usage() {
-	printf("echo [-n] [-e] [STRING]...\n"
-	       "  -n    do not output a new line at the end\n"
-	       "  -e    process escape sequences\n");
+void show_usage(char * argv[]) {
+	printf(
+			"echo - print arguments\n"
+			"\n"
+			"usage: %s [-ne] ARG...\n"
+			"\n"
+			" -n     \033[3mdo not output a new line at the end\033[0m\n"
+			" -e     \033[3mprocess escape sequences\033[0m\n"
+			" -?     \033[3mshow this help text\033[0m\n"
+			"\n", argv[0]);
 }
 
 int main(int argc, char ** argv) {
-	int start           = 1;
 	int use_newline     = 1;
 	int process_escapes = 0;
 
-	for (int i = start; i < argc; ++i) {
-		if (argv[i][0] != '-') {
-			start = i;
-			break;
-		} else {
-			start++;
-			if (argv[i][1] == 'h') {
-				usage();
+	int opt;
+	while ((opt = getopt(argc, argv, "enh?")) != -1) {
+		switch (opt) {
+			case '?':
+			case 'h':
+				show_usage(argv);
 				return 1;
-			} else if (argv[i][1] == 'n') {
+			case 'n':
 				use_newline = 0;
-			} else if (argv[i][1] == 'e') {
+				break;
+			case 'e':
 				process_escapes = 1;
-			}
+				break;
 		}
 	}
 
-	for (int i = start; i < argc; ++i) {
+	for (int i = optind; i < argc; ++i) {
 		if (process_escapes) {
 			for (int j = 0; j < (int)strlen(argv[i]) - 1; ++j) {
 				if (argv[i][j] == '\\') {

+ 14 - 14
apps/env.c

@@ -1,22 +1,22 @@
-/* This file is part of ToaruOS and is released under the terms
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2013-2018 K. Lange
+ *
+ * env - Print environment
+ *
+ * Prints all the environment values.
  */
 #include <stdio.h>
+#include <unistd.h>
 
 int main(int argc, char ** argv) {
-	unsigned int x = 0;
-	unsigned int nulls = 0;
-	for (x = 0; 1; ++x) {
-		if (!argv[x]) {
-			++nulls;
-			if (nulls == 2) {
-				break;
-			}
-			continue;
-		}
-		if (nulls == 1) {
-			printf("%s\n", argv[x]);
-		}
+	char ** env = environ;
+
+	while (*env) {
+		printf("%s\n", *env);
+		env++;
 	}
+
+	return 0;
 }

+ 2 - 2
apps/fetch.c

@@ -1,7 +1,7 @@
-/* vim: ts=4 sw=4 noexpandtab
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
  * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
- * Copyright (C) 2015 K. Lange
+ * Copyright (C) 2015-2018 K. Lange
  *
  * fetch - Retreive documents from HTTP servers.
  *

+ 15 - 12
apps/fgrep.c

@@ -1,9 +1,12 @@
-/* This file is part of ToaruOS and is released under the terms
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2014-2018 K. Lange
- */
-/*
- * Dump grep
+ *
+ * fgrep - dump grep
+ *
+ * Locates strings in files and prints the lines containing them,
+ * with extra color identification if stdout is a tty.
  */
 #include <stdio.h>
 #include <fcntl.h>
@@ -21,13 +24,18 @@ int main(int argc, char ** argv) {
 	char * needle = argv[1];
 	char buf[LINE_SIZE];
 	int ret = 1;
+	int is_tty = isatty(STDOUT_FILENO);
 
 	while (fgets(buf, LINE_SIZE, stdin)) {
 		char * found = strstr(buf, needle);
 		if (found) {
-			*found = '\0';
-			found += strlen(needle);
-			fprintf(stdout, "%s\033[1;31m%s\033[0m%s", buf, needle, found);
+			if (is_tty) {
+				*found = '\0';
+				found += strlen(needle);
+				fprintf(stdout, "%s\033[1;31m%s\033[0m%s", buf, needle, found);
+			} else {
+				fprintf(stdout, "%s", buf);
+			}
 			ret = 0;
 		}
 	}
@@ -35,8 +43,3 @@ int main(int argc, char ** argv) {
 	return ret;
 }
 
-/*
- * vim:tabstop=4
- * vim:noexpandtab
- * vim:shiftwidth=4
- */

+ 1 - 1
apps/hostname.c

@@ -1,4 +1,4 @@
-/* vim: ts=4 sw=4 noexpandtab
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
  * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2013-2018 K. Lange

+ 1 - 1
apps/init.c

@@ -1,4 +1,4 @@
-/* vim: ts=4 sw=4 noexpandtab
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
  * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2018 K. Lange

+ 5 - 1
apps/insmod.c

@@ -1,6 +1,10 @@
-/* This file is part of ToaruOS and is released under the terms
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2016 K. Lange
+ *
+ * insmod - Load kernel module
+ *
  */
 #include <stdio.h>
 #include <syscall.h>

+ 5 - 6
apps/irc.c

@@ -1,11 +1,10 @@
-/* vim: ts=4 sw=4 noexpandtab
- *
- * ToaruOS IRC Client v3
- *
- * Copyright 2018 K. Lange
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2018 K. Lange
  *
+ * irc - Internet Relay Chat client
  */
-
 #include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>

+ 2 - 2
apps/julia.c

@@ -1,9 +1,9 @@
-/* vim: ts=4 sw=4 noexpandtab
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
  * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2013-2018 K. Lange
  *
- * Julia Fractal Generator
+ * julia - Julia Fractal Generator
  *
  * This is the updated windowed version of the
  * julia fractal generator demo.

+ 4 - 1
apps/kdebug.c

@@ -1,6 +1,9 @@
-/* This file is part of ToaruOS and is released under the terms
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2014-2018 K. Lange
+ *
+ * kdebug - Launch kernel shell
  */
 #include <syscall.h>
 #include <sys/wait.h>

+ 6 - 5
apps/kill.c

@@ -1,10 +1,11 @@
-/* This file is part of ToaruOS and is released under the terms
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2013-2018 K. Lange
  *
- * kill
+ * kill - Send a signal to a process
  *
- * Send a signal to another process
+ * Supports signal names like any mature `kill` should.
  */
 #include <stdio.h>
 #include <string.h>
@@ -59,14 +60,14 @@ struct sig_def signals[] = {
 
 void usage(char * argv[]) {
 	printf(
-			"kill - send a signal to another process\n"
+			"%s - send a signal to another process\n"
 			"\n"
 			"usage: %s [-\033[3mx\033[0m] \033[3mprocess\033[0m\n"
 			"\n"
 			" -h --help       \033[3mShow this help message.\033[0m\n"
 			" -\033[3mx\033[0m              \033[3mSignal number to send\033[0m\n"
 			"\n",
-			argv[0]);
+			argv[0], argv[0]);
 }
 
 int main(int argc, char * argv[]) {

+ 2 - 2
apps/killall.c

@@ -1,9 +1,9 @@
-/* vim: ts=4 sw=4 noexpandtab
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
  * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2018 K. Lange
  *
- * killall
+ * killall - Send signals to processes matching name
  *
  * Find processes by name and send them signals.
  */

+ 9 - 0
apps/login-loop.c

@@ -1,3 +1,12 @@
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2018 K. Lange
+ *
+ * login-loop - Continuously call `login`
+ *
+ * Used by the VGA terminal to provide interactive login sessions.
+ */
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/wait.h>

+ 9 - 2
apps/menu.c

@@ -1,6 +1,13 @@
-/* vim: ts=4 sw=4 noexpandtab
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2018 K. Lange
  *
- * Menu tool / eventual library.
+ * menu - Display a menu file and print actions
+ *
+ * This is a demo of the menu library, and can be used by scripts
+ * to display menus. It may be broken without a root window for
+ * the menus to display on, though?
  */
 #include <stdio.h>
 #include <unistd.h>

+ 1 - 1
apps/nslookup.c

@@ -1,4 +1,4 @@
-/* vim: ts=4 sw=4 noexpandtab
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
  * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2016-2018 K. Lange

+ 1 - 1
apps/nyancat.c

@@ -1,4 +1,4 @@
-/*
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
  * Copyright (c) 2011-2018 K. Lange.  All rights reserved.
  *
  * Developed by:            K. Lange

+ 4 - 1
apps/piano.c

@@ -1,6 +1,9 @@
-/* This file is part of ToaruOS and is released under the terms
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2014-2018 K. Lange
+ *
+ * piano - Interactively make beeping noises
  */
 #include <stdio.h>
 #include <unistd.h>

+ 2 - 5
apps/pidof.c

@@ -1,14 +1,11 @@
-/* vim: ts=4 sw=4 noexpandtab
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
  * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2018 K. Lange
  *
- * pidof
+ * pidof - Find and print process IDs
  *
- * find and print process IDs
  */
-
-
 #include <sys/stat.h>
 #include <sys/signal.h>
 #include <fcntl.h>

+ 2 - 3
apps/plasma.c

@@ -1,11 +1,10 @@
-/* vim: ts=4 sw=4 noexpandtab
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
  * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2013-2018 K. Lange
  *
- * Plasma
+ * plasma - Draw animated plasma in a window
  *
- * Draws animated plasma in a decorated window.
  */
 #include <stdlib.h>
 #include <assert.h>

+ 7 - 1
apps/play.c

@@ -1,6 +1,12 @@
-/* This file is part of ToaruOS and is released under the terms
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2015-2018 K. Lange
+ *
+ * play - Play back PCM samples
+ *
+ * This needs very specifically-formatted PCM data to function
+ * properly - 16-bit, signed, stereo, little endian, and 48KHz.
  */
 
 #include <stdio.h>

+ 3 - 2
apps/pong.c

@@ -1,8 +1,9 @@
-/* This file is part of ToaruOS and is released under the terms
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2015 K. Lange
  *
- * Window Manager Pong
+ * pong - Window Manager Pong
  *
  * Play pong where the paddles and ball are all windows.
  * Use the WM bindings to drag the left paddle to play.

+ 4 - 7
apps/pstree.c

@@ -1,14 +1,11 @@
-/* This file is part of ToaruOS and is released under the terms
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2014-2018 K. Lange
- */
-/*
- * pstree
  *
- * Prints running processes as a tree of 
+ * pstree - Display a tree of running process
+ *
  */
-
-
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <stdint.h>

+ 3 - 2
apps/pwd.c

@@ -1,8 +1,9 @@
-/* This file is part of ToaruOS and is released under the terms
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2018 K. Lange
  *
- * pwd
+ * pwd - Print working directory
  */
 #include <unistd.h>
 #include <stdio.h>

+ 8 - 2
apps/readelf.c

@@ -1,8 +1,14 @@
-/* This file is part of ToaruOS and is released under the terms
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2013-2018 K Lange
+ *
+ * readelf - Show information about ELF objects
+ *
+ * This is a very custom implementation and nothing remotely
+ * like the version that comes with binutils. Making it more
+ * like that version might be worthwhile.
  */
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>

+ 4 - 5
apps/reboot.c

@@ -1,11 +1,10 @@
-/* This file is part of ToaruOS and is released under the terms
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2013-2014 K. Lange
- */
-/*
- * reboot
  *
- * Reboot the system.
+ * reboot - Reboot the system
+ *
  */
 #include <stdio.h>
 #include <syscall.h>

+ 3 - 5
apps/rm.c

@@ -1,11 +1,9 @@
-/* This file is part of ToaruOS and is released under the terms
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2013-2018 K. Lange
  *
- * rm
- *
- * unlink a file
- * (in theory)
+ * rm - Unlink files
  *
  * TODO: Support recursive, directory removal, etc.
  */

+ 3 - 2
apps/sdf-demo.c

@@ -1,9 +1,10 @@
-/* vim: ts=4 sw=4 noexpandtab
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
  * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2018 K. Lange
+ *
+ * sdf-demo - SDF font rasterizer demo
  */
-
 #include <stdio.h>
 #include <stdint.h>
 #include <string.h>

+ 4 - 9
apps/sleep.c

@@ -1,9 +1,9 @@
-/* This file is part of ToaruOS and is released under the terms
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2013 K. Lange
- */
-/*
- * Sleep
+ *
+ * sleep - Do nothing, efficiently.
  */
 #include <stdio.h>
 #include <stdlib.h>
@@ -25,8 +25,3 @@ int main(int argc, char ** argv) {
 	return ret;
 }
 
-/*
- * vim:tabstop=4
- * vim:noexpandtab
- * vim:shiftwidth=4
- */

+ 2 - 3
apps/sysfunc.c

@@ -1,8 +1,7 @@
-/* This file is part of ToaruOS and is released under the terms
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2013 K. Lange
- */
-/* vim:tabstop=4 shiftwidth=4 noexpandtab
  *
  * sysfunc
  *

+ 8 - 1
apps/term-size.c

@@ -1,6 +1,13 @@
-/* This file is part of ToaruOS and is released under the terms
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2013 K. Lange
+ *
+ * term-size - Print the size of the tty
+ *
+ * This is mostly redundant with ttysize, and should probably
+ * be replaced with setting COLUMNS and LINES in the shell,
+ * like bash does, but it's left here for historical reasons
  */
 #include <stdio.h>
 #include <sys/ioctl.h>

BIN
apps/terminal-font.h


+ 10 - 2
apps/terminal-palette.h

@@ -1,5 +1,13 @@
-/*
- * Terminal palette
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2012-2018 K. Lange
+ *
+ * terminal-palette.h - Terminal color palette
+ *
+ * Provides the color table for both the basic 16 colors (here,
+ * chosen from the Tango design documents), as well as the other
+ * colors making up the basic 256 color palette derived from xterm.
  */
 
 #define PALETTE_COLORS 256

+ 10 - 1
apps/toaru_logo.h

@@ -1,4 +1,13 @@
-/* GIMP RGBA C-Source image dump (toaru_logo.c) */
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2012 K. Lange
+ *
+ * toaru_logo.h - Generated by GIMP, ToaruOS logo
+ *
+ * Used by sysinfo. Can be used by other things as well.
+ * TODO: sysinfo should probably just load a bitmap?
+ */
 
 static const struct {
   unsigned int 	 width;

+ 11 - 0
apps/toggle-abs-mouse.c

@@ -1,3 +1,14 @@
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2018 K. Lange
+ *
+ * toggle-abs-mouse - Toggle mouse modes
+ *
+ * Set the mouse mode under VirtualBox, VMware, or QEMU to either
+ * relative or absolute via ioctl to the relevant absolute mouse
+ * device driver interface.
+ */
 #include <string.h>
 #include <stdio.h>
 #include <unistd.h>

+ 3 - 4
apps/touch.c

@@ -1,11 +1,10 @@
-/* This file is part of ToaruOS and is released under the terms
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2013 K. Lange
  *
- * touch
+ * touch - Create or update file timestamps
  *
- * Creates a file or updates its last-modified date.
- * (in theory)
  */
 #include <stdio.h>
 #include <string.h>

+ 7 - 0
apps/true.c

@@ -1,3 +1,10 @@
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2018 K. Lange
+ *
+ * true - Return success code
+ */
 int main() {
 	return 0;
 }

+ 15 - 0
apps/ttysize.c

@@ -1,3 +1,18 @@
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2018 K. Lange
+ *
+ * ttysize - Magically divine terminal size
+ *
+ * This is called by getty to determine the size of foreign
+ * terminals, such as ones attached over serial.
+ *
+ * It works by placing the cursor in the lower right of the
+ * screen and requesting its position. Note that typing things
+ * while this happens can cause problems. Maybe we can flush
+ * stdin before doing this to try to avoid any conflicting data?
+ */
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>

+ 9 - 5
apps/uname.c

@@ -1,12 +1,16 @@
-/* This file is part of ToaruOS and is released under the terms
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2018 K. Lange
- */
-/* vim: tabstop=4 shiftwidth=4 noexpandtab
  *
- * uname
+ * uname - Print kernel version information
+ *
+ * Supports all the usual options (a,s,n,r,v,m,o)
  *
- * Prints the kernel version information.
+ * Note that o is hardcoded, which is also the situation in
+ * the coreutils implementation, so I don't see that being
+ * a problem. If you want to build this uname for Linux or
+ * something... you'll have to change that.
  */
 #include <stdio.h>
 #include <stdlib.h>

+ 13 - 0
apps/vga-palette.h

@@ -1,3 +1,16 @@
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2012-2018 K. Lange
+ *
+ * vga-palette.h - 256-to-VGA palette
+ *
+ * Converts 256-color index values to closest matching 16-color
+ * value for the VGA terminal. Note that values here are terminal
+ * color codes, not the VGA color codes - the terminal converts
+ * them to VGA color codes later. This was automatically generated
+ * from a script, but I don't know where that script went.
+ */
 #define PALETTE_COLORS 256
 uint32_t vga_colors[PALETTE_COLORS] = {
 	0x0,

+ 7 - 4
apps/which.c

@@ -1,17 +1,20 @@
-/* This file is part of ToaruOS and is released under the terms
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2013-2014 K. Lange
  *
- * which
+ * which - Figure out which binary will be used
  *
- * Searches through PATH to find an executable.
+ * Searches through $PATH to find a matching binary, just like
+ * how execp* family does it. (Except does our execp actually
+ * bother checking permissions? Look into this...)
  */
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/stat.h>
 
-#define DEFAULT_PATH ".:/bin:/usr/bin"
+#define DEFAULT_PATH "/bin:/usr/bin"
 
 int main(int argc, char * argv[]) {
 

+ 3 - 4
apps/yes.c

@@ -1,10 +1,9 @@
-/* This file is part of ToaruOS and is released under the terms
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2013 K Lange
- */
-/* vim: tabstop=4 shiftwidth=4 noexpandtab
  *
- * yes
+ * yes - Continually print stuff
  *
  * Continually prints its first argument, followed by a newline.
  */

+ 3 - 2
apps/yutani-test.c

@@ -1,8 +1,9 @@
-/* This file is part of ToaruOS and is released under the terms
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
  * of the NCSA / University of Illinois License - see LICENSE.md
  * Copyright (C) 2015-2018 K. Lange
  *
- * Yutani Test Tool
+ * yutani-test - Yutani Test Tool
  *
  * Kinda like xev: Pops up a window and displays events in a
  * human-readable format.

+ 0 - 192
apps/yutani_int.h

@@ -1,192 +0,0 @@
-#pragma once
-
-#include <toaru/yutani.h>
-#include <toaru/list.h>
-#include <toaru/hashmap.h>
-#include <toaru/graphics.h>
-#include <toaru/kbd.h>
-
-#define MOUSE_SCALE 3
-#define MOUSE_OFFSET_X 26
-#define MOUSE_OFFSET_Y 26
-
-#define YUTANI_BYTE_DEPTH 4
-
-#define YUTANI_SCREENSHOT_FULL 1
-#define YUTANI_SCREENSHOT_WINDOW 2
-
-typedef enum {
-	YUTANI_EFFECT_NONE,
-	YUTANI_EFFECT_FADE_IN,
-	YUTANI_EFFECT_FADE_OUT,
-	YUTANI_EFFECT_MINIMIZE,
-	YUTANI_EFFECT_UNMINIMIZE,
-} yutani_effect;
-
-static int yutani_animation_lengths[] = {
-	0,
-	200,
-	200,
-	0,
-	0,
-};
-
-typedef struct {
-	yutani_wid_t wid;
-
-	signed long x;
-	signed long y;
-	unsigned short z;
-
-	int32_t width;
-	int32_t height;
-
-	uint8_t * buffer;
-	uint32_t bufid;
-
-	uint32_t owner;
-
-	int16_t  rotation;
-
-	uint32_t newbufid;
-	uint8_t * newbuffer;
-
-	uint32_t client_flags;
-	uint16_t client_offsets[5];
-	uint32_t client_length;
-	char *   client_strings;
-
-	int anim_mode;
-	uint32_t anim_start;
-
-	int alpha_threshold;
-	int show_mouse;
-
-	int tiled;
-	int32_t untiled_width;
-	int32_t untiled_height;
-	int32_t untiled_left;
-	int32_t untiled_top;
-
-	int default_mouse;
-	uint32_t server_flags;
-
-	int opacity;
-} yutani_server_window_t;
-
-typedef struct {
-	/* XXX multiple displays */
-	unsigned int width;
-	unsigned int height;
-
-	void * backend_framebuffer;
-	gfx_context_t * backend_ctx;
-
-	signed int mouse_x;
-	signed int mouse_y;
-
-	signed int last_mouse_x;
-	signed int last_mouse_y;
-
-	list_t * windows;
-	hashmap_t * wids_to_windows;
-
-	yutani_server_window_t * bottom_z;
-	list_t * mid_zs;
-	yutani_server_window_t * top_z;
-
-	list_t * update_list;
-	volatile int update_list_lock;
-
-	sprite_t mouse_sprite;
-
-	char * server_ident;
-
-	yutani_server_window_t * focused_window;
-	FILE * server;
-
-	int mouse_state;
-	yutani_server_window_t * mouse_window;
-
-	int mouse_win_x;
-	int mouse_win_y;
-	int mouse_init_x;
-	int mouse_init_y;
-	int mouse_init_r;
-
-	int mouse_drag_button;
-	int mouse_moved;
-
-	int32_t mouse_click_x;
-	int32_t mouse_click_y;
-
-	key_event_state_t kbd_state;
-
-	yutani_server_window_t * resizing_window;
-	int32_t resizing_w;
-	int32_t resizing_h;
-
-	list_t * window_subscribers;
-
-	time_t start_time;
-
-	volatile int redraw_lock;
-
-	yutani_server_window_t * old_hover_window;
-
-	hashmap_t * key_binds;
-
-	list_t * windows_to_remove;
-
-	yutani_t * host_context;
-	yutani_window_t * host_window;
-
-	hashmap_t * clients_to_windows;
-
-	int debug_bounds;
-	int debug_shapes;
-
-	int screenshot_frame;
-
-	suseconds_t start_subtime;
-
-	yutani_scale_direction_t resizing_direction;
-	int32_t resizing_offset_x;
-	int32_t resizing_offset_y;
-	int resizing_button;
-
-	sprite_t mouse_sprite_drag;
-	sprite_t mouse_sprite_resize_v;
-	sprite_t mouse_sprite_resize_h;
-	sprite_t mouse_sprite_resize_da;
-	sprite_t mouse_sprite_resize_db;
-
-	int current_cursor;
-	int resize_on_next;
-
-	uint32_t timer_precison;
-	list_t * timer_subscribers;
-
-	uint32_t last_mouse_buttons;
-
-	uint32_t stride;
-
-	int32_t mouse_click_x_orig;
-	int32_t mouse_click_y_orig;
-
-	char clipboard[512];
-	int clipboard_size;
-
-	int vbox_rects;
-	int vbox_pointer;
-} yutani_globals_t;
-
-struct key_bind {
-	unsigned int owner;
-	int response;
-};
-
-static void mark_window(yutani_globals_t * yg, yutani_server_window_t * window);
-static void window_actually_close(yutani_globals_t * yg, yutani_server_window_t * w);
-static void notify_subscribers(yutani_globals_t * yg);
-