Changeset 42942 for trunk/Ohana/src/opihi/cmd.data/section.c
- Timestamp:
- Nov 12, 2025, 5:00:47 PM (8 months ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/cmd.data/section.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.data/section.c
r31160 r42942 1 1 # include "data.h" 2 2 3 enum {NONE, LIST, UP, DOWN, TOP, BOTTOM, TOOL, BG, IMAGE };3 enum {NONE, LIST, UP, DOWN, TOP, BOTTOM, TOOL, BG, IMAGE, IMCENTER}; 4 4 5 5 int section (int argc, char **argv) { … … 17 17 } 18 18 if ((N = get_argument (argc, argv, "-up"))) { 19 if (action != NONE) goto escape; 19 20 action = UP; 20 21 remove_argument (N, &argc, argv); 21 22 } 22 23 if ((N = get_argument (argc, argv, "-down"))) { 24 if (action != NONE) goto escape; 23 25 action = DOWN; 24 26 remove_argument (N, &argc, argv); 25 27 } 26 28 if ((N = get_argument (argc, argv, "-top"))) { 29 if (action != NONE) goto escape; 27 30 action = TOP; 28 31 remove_argument (N, &argc, argv); 29 32 } 30 33 if ((N = get_argument (argc, argv, "-bottom"))) { 34 if (action != NONE) goto escape; 31 35 action = BOTTOM; 32 36 remove_argument (N, &argc, argv); 33 37 } 34 38 if ((N = get_argument (argc, argv, "-imtool"))) { 39 if (action != NONE) goto escape; 35 40 action = TOOL; 36 41 remove_argument (N, &argc, argv); … … 41 46 background = -1; // invisible 42 47 if ((N = get_argument (argc, argv, "-bg"))) { 48 if (action != NONE) goto escape; 43 49 remove_argument (N, &argc, argv); 44 50 if (!strcasecmp (argv[N], "NONE")) { … … 52 58 53 59 if ((N = get_argument (argc, argv, "-image"))) { 60 if (action != NONE) goto escape; 54 61 remove_argument (N, &argc, argv); 55 62 action = IMAGE; 63 } 64 65 if ((N = get_argument (argc, argv, "-imcenter"))) { 66 if (action != NONE) goto escape; 67 remove_argument (N, &argc, argv); 68 action = IMCENTER; 56 69 } 57 70 … … 65 78 FREE (name); 66 79 67 /* list sections */ 68 if ((argc == 1) && (action == NONE)) { 69 KapaGetSection (kapa, "*"); 70 gprint (GP_ERR, "USAGE: section name [x y dx dy] or [options]\n"); 71 gprint (GP_ERR, "OPTIONS: -list : show properties of all sections\n"); 72 gprint (GP_ERR, " -up : move section up in display stack\n"); 73 gprint (GP_ERR, " -down : move section down in display stack\n"); 74 gprint (GP_ERR, " -top : move section to top of display stack\n"); 75 gprint (GP_ERR, " -bottom : move section to bottom of display stack\n"); 76 gprint (GP_ERR, " -imtool (position) : set location of image zoom / status box\n"); 77 gprint (GP_ERR, " (position may be: -x, +x, -y, +y, none)\n"); 78 gprint (GP_ERR, " -image : define section upper-right corner so image fills the section\n"); 79 gprint (GP_ERR, " -bg (color) : set background color (see style -c help for color choices)\n"); 80 81 return (TRUE); 82 } 83 84 if ((argc != 2) && (action != NONE)) { 85 gprint (GP_ERR, "can only use dash options without numbers\n"); 80 // deal with these cases first 81 if (action == NONE) { 82 if (argc == 1) { // command: section 83 gprint (GP_ERR, "USAGE: section name x y dx dy\n"); 84 gprint (GP_ERR, " section name -image x y\n"); 85 gprint (GP_ERR, " section name [options]\n"); 86 gprint (GP_ERR, "OPTIONS: -list : show properties of all sections\n"); 87 gprint (GP_ERR, " -up : move section up in display stack\n"); 88 gprint (GP_ERR, " -down : move section down in display stack\n"); 89 gprint (GP_ERR, " -top : move section to top of display stack\n"); 90 gprint (GP_ERR, " -bottom : move section to bottom of display stack\n"); 91 gprint (GP_ERR, " -imtool (position) : set location of image zoom / status box\n"); 92 gprint (GP_ERR, " (position may be: -x, +x, -y, +y, none)\n"); 93 gprint (GP_ERR, " -image : define section upper-right corner so image fills the section\n"); 94 gprint (GP_ERR, " -bg (color) : set background color (see style -c help for color choices or use NONE)\n"); 95 return (TRUE); 96 } 97 if (argc == 2) { // command: section name 98 KapaSelectSection (kapa, argv[1]); 99 return TRUE; 100 } 101 if (argc == 6) { // command: section name x y dx dy 102 /* set section */ 103 section.name = argv[1]; 104 section.x = atof (argv[2]); 105 section.y = atof (argv[3]); 106 section.dx = atof (argv[4]); 107 section.dy = atof (argv[5]); 108 section.bg = -2; // bg must be set on its own 109 KapaSetSection (kapa, §ion); 110 return (TRUE); 111 } 112 goto escape; 113 } 114 115 // list properties of the specified section, or all sections 116 if (action == LIST) { 117 if (argc == 1) { 118 KapaGetSection (kapa, "*"); 119 return TRUE; 120 } 121 if (argc == 2) { 122 KapaGetSection (kapa, argv[1]); 123 KapaSelectSection (kapa, argv[1]); 124 return TRUE; 125 } 126 goto escape; 127 } 128 129 if ((action == IMAGE) || (action == IMCENTER)) { 130 if (argc != 4) goto escape; 131 } else { 132 if (argc != 2) goto escape; 133 } 134 135 /* select / show section */ 136 switch (action) { 137 case UP: 138 KapaMoveSection (kapa, argv[1], "up"); 139 break; 140 case DOWN: 141 KapaMoveSection (kapa, argv[1], "down"); 142 break; 143 case TOP: 144 KapaMoveSection (kapa, argv[1], "top"); 145 break; 146 case BOTTOM: 147 KapaMoveSection (kapa, argv[1], "bottom"); 148 break; 149 150 case BG: 151 KapaSectionBG (kapa, argv[1], background); 152 break; 153 154 case TOOL: 155 KapaSelectSection (kapa, argv[1]); 156 if (!strcmp(location, "-x")) { 157 KapaSetToolbox (kapa, 1); 158 break; 159 } 160 if (!strcmp(location, "+x")) { 161 KapaSetToolbox (kapa, 3); 162 break; 163 } 164 if (!strcmp(location, "-y")) { 165 KapaSetToolbox (kapa, 2); 166 break; 167 } 168 if (!strcmp(location, "+y")) { 169 KapaSetToolbox (kapa, 4); 170 break; 171 } 172 if (!strcmp(location, "none")) { 173 KapaSetToolbox (kapa, 0); 174 break; 175 } 176 gprint (GP_ERR, "unknown toolbox location %s\n", location); 177 gprint (GP_ERR, "valid values: -x, +x, -y, +y, none\n"); 86 178 return (FALSE); 87 } 88 89 if (argc == 2) { 90 /* select / show section */ 91 switch (action) { 92 case NONE: 93 KapaSelectSection (kapa, argv[1]); 94 break; 95 96 case UP: 97 KapaMoveSection (kapa, argv[1], "up"); 98 break; 99 case DOWN: 100 KapaMoveSection (kapa, argv[1], "down"); 101 break; 102 case TOP: 103 KapaMoveSection (kapa, argv[1], "top"); 104 break; 105 case BOTTOM: 106 KapaMoveSection (kapa, argv[1], "bottom"); 107 break; 108 109 case BG: 110 KapaSectionBG (kapa, argv[1], background); 111 break; 112 113 case TOOL: 114 if (!strcmp(location, "-x")) { 115 KapaSetToolbox (kapa, 1); 116 break; 117 } 118 if (!strcmp(location, "+x")) { 119 KapaSetToolbox (kapa, 3); 120 break; 121 } 122 if (!strcmp(location, "-y")) { 123 KapaSetToolbox (kapa, 2); 124 break; 125 } 126 if (!strcmp(location, "+y")) { 127 KapaSetToolbox (kapa, 4); 128 break; 129 } 130 if (!strcmp(location, "none")) { 131 KapaSetToolbox (kapa, 0); 132 break; 133 } 134 gprint (GP_ERR, "unknown toolbox location %s\n", location); 135 gprint (GP_ERR, "valid values: -x, +x, -y, +y, none\n"); 136 return (FALSE); 137 138 case LIST: 139 KapaGetSection (kapa, argv[1]); 140 break; 141 } 142 return (TRUE); 143 } 144 145 if (argc == 4) { 146 /* set section */ 147 section.name = argv[1]; 148 section.x = atof (argv[2]); 149 section.y = atof (argv[3]); 150 section.bg = background; 151 KapaSetSectionByImage (kapa, §ion); 152 return (TRUE); 153 } 154 155 if (argc == 6) { 156 /* set section */ 157 section.name = argv[1]; 158 section.x = atof (argv[2]); 159 section.y = atof (argv[3]); 160 section.dx = atof (argv[4]); 161 section.dy = atof (argv[5]); 162 section.bg = background; 163 KapaSetSection (kapa, §ion); 164 return (TRUE); 165 } 166 gprint (GP_ERR, "USAGE: section name [x y dx dy]\n"); 167 gprint (GP_ERR, "USAGE: section name [-image x y] : width based on current image\n"); 168 gprint (GP_ERR, "USAGE: section name [-list] [-up] [-down] [-top] [-bottom]\n"); 179 180 case IMAGE: 181 /* set section */ 182 section.name = argv[1]; 183 section.x = atof (argv[2]); 184 section.y = atof (argv[3]); 185 section.bg = -2; 186 KapaSetSectionByImage (kapa, §ion); 187 return (TRUE); 188 189 case IMCENTER: 190 /* set section */ 191 section.name = argv[1]; 192 section.x = atof (argv[2]); 193 section.y = atof (argv[3]); 194 KapaSetSectionCenterByImage (kapa, §ion); 195 return (TRUE); 196 197 case NONE: 198 case LIST: 199 default: 200 gprint (GP_ERR, "oops, programming error in section.c:171\n"); 201 break; 202 } 203 return (TRUE); 204 205 escape: 206 gprint (GP_ERR, "USAGE: section name : select the section\n"); 207 gprint (GP_ERR, "USAGE: section name x y dx dy : define section location\n"); 208 gprint (GP_ERR, "USAGE: section name -image x y : width based on current image\n"); 209 gprint (GP_ERR, "USAGE: section name -imtool (position) : width based on current image\n"); 210 gprint (GP_ERR, "USAGE: section name [-list] [-up] [-down] [-top] [-bottom] [-bg color]\n"); 211 gprint (GP_ERR, " only one -OPTION at a time\n"); 169 212 return (FALSE); 170 213 }
Note:
See TracChangeset
for help on using the changeset viewer.
