shithub: da

Download patch

ref: ab2f400e8b8b52bab59a5d0ced217807f2aa2e3c
parent: 02c13a3ce3bcf6e19dcf794c4efa57d4056b2d4c
author: glenda <glenda@krsna>
date: Wed Aug 20 16:52:14 EDT 2025

clean-up

--- a/da.c
+++ b/da.c
@@ -193,8 +193,8 @@
 void initcolors(void);
 void validate_config(void);
 void apply_config(void);
-int addbox(Point p);
 void delbox(int i);
+int addbox(Point p);
 int boxat(Point p);
 
 static ulong palette[] = {
@@ -673,12 +673,9 @@
     
     b = Bfdopen(fd, OWRITE);
     
-    // New format - write arrays in bulk
     Bprint(b, "count %d\n", canvas.nboxes);
     
-    // Write all data in array chunks - much more efficient!
     
-    // Positions array
     Bprint(b, "positions\n");
     for(i = 0; i < canvas.nboxes; i++){
         Bprint(b, "%d %d\n", 
@@ -686,13 +683,11 @@
             canvas.boxes.pos[i].y);
     }
     
-    // Types array
     Bprint(b, "types\n");
     for(i = 0; i < canvas.nboxes; i++){
         Bprint(b, "%d\n", canvas.boxes.type[i]);
     }
     
-    // Colors array  
     Bprint(b, "colors\n");
     for(i = 0; i < canvas.nboxes; i++){
         Bprint(b, "%d\n", canvas.boxes.color_idx[i]);
@@ -719,7 +714,6 @@
         return;
     }
     
-    // Clear canvas
     memset(&canvas.boxes, 0, sizeof(canvas.boxes));
     canvas.nboxes = 0;
     canvas.selected = -1;
@@ -735,7 +729,6 @@
         nf = tokenize(line, fields, nelem(fields));
         if(nf == 0) continue;
         
-        // Check for section headers 
 		if(strcmp(fields[0], "count") == 0 && nf >= 2){
             count = atoi(fields[1]);
             if(count > MAXBOXES) count = MAXBOXES;
@@ -749,7 +742,6 @@
             section = COLORS;
             idx = 0;
         } else {
-            // Parse data based on current section
             switch(section){
             case POSITIONS:
                 if(nf >= 2 && idx < count){
@@ -777,7 +769,6 @@
     
     canvas.nboxes = count;
     
-    // Reconstruct rectangles from positions and types
     for(i = 0; i < canvas.nboxes; i++){
         Point p = canvas.boxes.pos[i];
         if(canvas.boxes.type[i] == T_BIGBOX){
@@ -905,7 +896,7 @@
 					break;
 				}
 
-				break;	/* Found, next line */
+				break; /* next line */
 			}
 		}
 
@@ -1189,7 +1180,6 @@
 draw_all(void)
 {
     int i;
-    // First pass: Draw all regular boxes
     for(i = 0; i < canvas.nboxes; i++) {
         if(canvas.boxes.type[i] == T_BOX) {
             Image *color = colors[canvas.boxes.color_idx[i]];
@@ -1197,7 +1187,6 @@
         }
     }
     
-    // Second pass: Draw all big boxes  
     for(i = 0; i < canvas.nboxes; i++) {
         if(canvas.boxes.type[i] == T_BIGBOX) {
             Image *color = colors[canvas.boxes.color_idx[i]];
@@ -1205,7 +1194,6 @@
         }
     }
     
-    // Third pass: Draw selection highlights
     for(i = 0; i < canvas.nboxes; i++) {
         if(canvas.boxes.selected[i]) {
             border(screen, canvas.boxes.r[i], 2, boxselected, ZP);
@@ -1212,6 +1200,7 @@
         }
     }
 }
+
 void
 draw_status(void)
 {
@@ -1306,7 +1295,7 @@
     static int emoji_set = 0;
     int i;
     
-    emoji_set = (emoji_set + 1) % 51;  /* 45 total emoji sets */
+    emoji_set = (emoji_set + 1) % 51;  /* total emoji sets */
     
     switch(emoji_set) {
     case 0:
@@ -1594,12 +1583,12 @@
 {
 	Command *cmd;	
 	if(key >= '0' && key <= '9') {
-        cmd_set_color(key - '0');  // Pass the index
+        cmd_set_color(key - '0'); 
         return;
     }
     
     if(key >= 'a' && key <= 'f') {
-        cmd_set_color(10 + (key - 'a'));  // Pass the index
+        cmd_set_color(10 + (key - 'a'));  
         return;
     }
 
@@ -1672,7 +1661,6 @@
         i = boxat(m.xy);
         if(i >= 0){
             canvas.selected = i;
-            // Access arrays directly, not through pointer
             int type = canvas.boxes.type[i];
             int width = (type == T_BIGBOX) ? config.bigbox_width : config.box_width;
             int height = (type == T_BIGBOX) ? config.bigbox_height : config.box_height;
@@ -1711,12 +1699,13 @@
 {
 	USED(m);
 }
+
 void
 ctl_addbox(char **args, int nargs)
 {
-    USED(nargs);  // Add this
+    USED(nargs);  
     Point p = Pt(atoi(args[0]), atoi(args[1]));
-    addbox(p);     // Don't need to capture idx if not using it
+    addbox(p);
     canvas.needredraw = 1;
 }
 
--