patch-acme3k (14402B)
1 diff -u a/src/cmd/acme/acme.c b/src/cmd/acme/acme.c 2 --- a/src/cmd/acme/acme.c Sun Nov 10 21:20:26 2024 3 +++ b/src/cmd/acme/acme.c Sun Nov 10 21:19:53 2024 4 @@ -11,6 +11,7 @@ 5 #include <libsec.h> 6 #include "dat.h" 7 #include "fns.h" 8 +#include "config.h" 9 /* for generating syms in mkfile only: */ 10 #include <bio.h> 11 #include "edit.h" 12 @@ -547,7 +548,7 @@ 13 case MResize: 14 if(getwindow(display, Refnone) < 0) 15 error("attach to window"); 16 - draw(screen, screen->r, display->white, nil, ZP); 17 + draw(screen, screen->r, framecols[BACK], nil, ZP); 18 iconinit(); 19 scrlresize(); 20 rowresize(&row, screen->clipr); 21 @@ -1039,19 +1040,27 @@ 22 Image *tmp; 23 24 if(tagcols[BACK] == nil) { 25 - /* Blue */ 26 - tagcols[BACK] = allocimagemix(display, DPalebluegreen, DWhite); 27 - tagcols[HIGH] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DPalegreygreen); 28 - tagcols[BORD] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DPurpleblue); 29 - tagcols[TEXT] = display->black; 30 - tagcols[HTEXT] = display->black; 31 + tagcols[BACK] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, taghexcols[BACK]); 32 + tagcols[HIGH] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, taghexcols[HIGH]); 33 + tagcols[BORD] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, taghexcols[BORD]); 34 + tagcols[TEXT] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, taghexcols[TEXT]); 35 + tagcols[HTEXT] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, taghexcols[HTEXT]); 36 37 - /* Yellow */ 38 - textcols[BACK] = allocimagemix(display, DPaleyellow, DWhite); 39 - textcols[HIGH] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DDarkyellow); 40 - textcols[BORD] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DYellowgreen); 41 - textcols[TEXT] = display->black; 42 - textcols[HTEXT] = display->black; 43 + textcols[BACK] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, texthexcols[BACK]); 44 + textcols[HIGH] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, texthexcols[HIGH]); 45 + textcols[BORD] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, texthexcols[BORD]); 46 + textcols[TEXT] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, texthexcols[TEXT]); 47 + textcols[HTEXT] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, texthexcols[HTEXT]); 48 + 49 + framecols[BACK] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, framehexcols[BACK]); 50 + framecols[BORD] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, framehexcols[BORD]); 51 + framecols[TEXT] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, framehexcols[TEXT]); 52 + 53 + button2cols[BACK] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, button2hexcols[BACK]); 54 + button2cols[TEXT] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, button2hexcols[TEXT]); 55 + 56 + button3cols[BACK] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, button3hexcols[BACK]); 57 + button3cols[TEXT] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, button3hexcols[TEXT]); 58 } 59 60 r = Rect(0, 0, Scrollwid, font->height+1); 61 @@ -1066,22 +1075,19 @@ 62 63 button = allocimage(display, r, screen->chan, 0, DNofill); 64 draw(button, r, tagcols[BACK], nil, r.min); 65 - border(button, r, ButtonBorder, tagcols[BORD], ZP); 66 + border(button, r, ButtonBorder, framecols[TEXT], ZP); 67 68 r = button->r; 69 modbutton = allocimage(display, r, screen->chan, 0, DNofill); 70 draw(modbutton, r, tagcols[BACK], nil, r.min); 71 - border(modbutton, r, ButtonBorder, tagcols[BORD], ZP); 72 + border(modbutton, r, ButtonBorder, framecols[TEXT], ZP); 73 r = insetrect(r, ButtonBorder); 74 - tmp = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DMedblue); 75 + tmp = allocimage(display, Rect(0,0,1,1), screen->chan, 1, framehexcols[HIGH]); 76 draw(modbutton, r, tmp, nil, ZP); 77 freeimage(tmp); 78 79 r = button->r; 80 - colbutton = allocimage(display, r, screen->chan, 0, DPurpleblue); 81 - 82 - but2col = allocimage(display, r, screen->chan, 1, 0xAA0000FF); 83 - but3col = allocimage(display, r, screen->chan, 1, 0x006600FF); 84 + colbutton = allocimage(display, r, screen->chan, 0, framehexcols[HTEXT]); 85 } 86 87 /* 88 diff -u a/src/cmd/acme/cols.c b/src/cmd/acme/cols.c 89 --- a/src/cmd/acme/cols.c Sun Nov 10 21:20:26 2024 90 +++ b/src/cmd/acme/cols.c Sun Nov 10 21:19:53 2024 91 @@ -29,7 +29,7 @@ 92 Rectangle r1; 93 Text *t; 94 95 - draw(screen, r, display->white, nil, ZP); 96 + draw(screen, r, framecols[BACK], nil, ZP); 97 c->r = r; 98 c->w = nil; 99 c->nw = 0; 100 @@ -42,7 +42,7 @@ 101 t->what = Columntag; 102 r1.min.y = r1.max.y; 103 r1.max.y += Border; 104 - draw(screen, r1, display->black, nil, ZP); 105 + draw(screen, r1, framecols[BORD], nil, ZP); 106 textinsert(t, 0, Lheader, 38, TRUE); 107 textsetselect(t, t->file->b.nc, t->file->b.nc); 108 draw(screen, t->scrollr, colbutton, nil, colbutton->r.min); 109 @@ -117,7 +117,7 @@ 110 r1.max.y = min(y, v->body.fr.r.min.y+v->body.fr.nlines*v->body.fr.font->height); 111 r1.min.y = winresize(v, r1, FALSE, FALSE); 112 r1.max.y = r1.min.y+Border; 113 - draw(screen, r1, display->black, nil, ZP); 114 + draw(screen, r1, framecols[BORD], nil, ZP); 115 116 /* 117 * leave r with w's coordinates 118 @@ -184,7 +184,7 @@ 119 memmove(c->w+i, c->w+i+1, (c->nw-i)*sizeof(Window*)); 120 c->w = realloc(c->w, c->nw*sizeof(Window*)); 121 if(c->nw == 0){ 122 - draw(screen, r, display->white, nil, ZP); 123 + draw(screen, r, framecols[BACK], nil, ZP); 124 return; 125 } 126 up = 0; 127 @@ -246,7 +246,7 @@ 128 draw(screen, c->tag.scrollr, colbutton, nil, colbutton->r.min); 129 r1.min.y = r1.max.y; 130 r1.max.y += Border; 131 - draw(screen, r1, display->black, nil, ZP); 132 + draw(screen, r1, framecols[BORD], nil, ZP); 133 r1.max.y = r.max.y; 134 new = Dy(r) - c->nw*(Border + font->height); 135 old = Dy(c->r) - c->nw*(Border + font->height); 136 @@ -264,7 +264,7 @@ 137 r1.max.y = max(r1.max.y, r1.min.y + Border+font->height); 138 r2 = r1; 139 r2.max.y = r2.min.y+Border; 140 - draw(screen, r2, display->black, nil, ZP); 141 + draw(screen, r2, framecols[BORD], nil, ZP); 142 r1.min.y = r2.max.y; 143 r1.min.y = winresize(w, r1, FALSE, i==c->nw-1); 144 } 145 @@ -320,7 +320,7 @@ 146 r.max.y = r.min.y+Dy(w->r)+Border; 147 r1 = r; 148 r1.max.y = r1.min.y+Border; 149 - draw(screen, r1, display->black, nil, ZP); 150 + draw(screen, r1, framecols[BORD], nil, ZP); 151 r.min.y = r1.max.y; 152 y = winresize(w, r, FALSE, i==c->nw-1); 153 } 154 @@ -418,7 +418,7 @@ 155 r.max.y += 1 + nl[j]*v->body.fr.font->height; 156 r.min.y = winresize(v, r, c->safe, FALSE); 157 r.max.y = r.min.y + Border; 158 - draw(screen, r, display->black, nil, ZP); 159 + draw(screen, r, framecols[BORD], nil, ZP); 160 y1 = r.max.y; 161 } 162 /* scan to see new size of everyone below */ 163 @@ -445,7 +445,7 @@ 164 if(i < c->nw-1){ 165 r.min.y = r.max.y; 166 r.max.y += Border; 167 - draw(screen, r, display->black, nil, ZP); 168 + draw(screen, r, framecols[BORD], nil, ZP); 169 for(j=i+1; j<c->nw; j++) 170 ny[j] -= (y2-r.max.y); 171 } 172 @@ -462,7 +462,7 @@ 173 if(j < c->nw-1){ /* no border on last window */ 174 r.min.y = y1; 175 r.max.y += Border; 176 - draw(screen, r, display->black, nil, ZP); 177 + draw(screen, r, framecols[BORD], nil, ZP); 178 y1 = r.max.y; 179 } 180 } 181 @@ -544,7 +544,7 @@ 182 } 183 r.min.y = winresize(v, r, c->safe, FALSE); 184 r.max.y = r.min.y+Border; 185 - draw(screen, r, display->black, nil, ZP); 186 + draw(screen, r, framecols[BORD], nil, ZP); 187 r.min.y = r.max.y; 188 if(i == c->nw-1) 189 r.max.y = c->r.max.y; 190 Only in b/src/cmd/acme: config.def.h 191 Only in b/src/cmd/acme: config.h 192 diff -u a/src/cmd/acme/dat.h b/src/cmd/acme/dat.h 193 --- a/src/cmd/acme/dat.h Sun Nov 10 21:20:26 2024 194 +++ b/src/cmd/acme/dat.h Sun Nov 10 21:19:53 2024 195 @@ -222,7 +222,7 @@ 196 void textscroll(Text*, int); 197 void textselect(Text*); 198 int textselect2(Text*, uint*, uint*, Text**); 199 -int textselect23(Text*, uint*, uint*, Image*, int); 200 +int textselect23(Text*, uint*, uint*, Image*, Image*, int); 201 int textselect3(Text*, uint*, uint*); 202 void textsetorigin(Text*, uint, int); 203 void textsetselect(Text*, uint, uint); 204 @@ -522,8 +522,6 @@ 205 Image *modbutton; 206 Image *colbutton; 207 Image *button; 208 -Image *but2col; 209 -Image *but3col; 210 Cursor boxcursor; 211 Cursor2 boxcursor2; 212 Row row; 213 @@ -548,6 +546,9 @@ 214 char *fontnames[2]; 215 Image *tagcols[NCOL]; 216 Image *textcols[NCOL]; 217 +Image *framecols[NCOL]; 218 +Image *button2cols[NCOL]; 219 +Image *button3cols[NCOL]; 220 extern char wdir[]; /* must use extern because no dimension given */ 221 int editing; 222 int erroutfd; 223 Common subdirectories: a/src/cmd/acme/mail and b/src/cmd/acme/mail 224 diff -u a/src/cmd/acme/rows.c b/src/cmd/acme/rows.c 225 --- a/src/cmd/acme/rows.c Sun Nov 10 21:20:26 2024 226 +++ b/src/cmd/acme/rows.c Sun Nov 10 21:19:54 2024 227 @@ -28,7 +28,7 @@ 228 Rectangle r1; 229 Text *t; 230 231 - draw(screen, r, display->white, nil, ZP); 232 + draw(screen, r, framecols[BACK], nil, ZP); 233 row->r = r; 234 row->col = nil; 235 row->ncol = 0; 236 @@ -42,7 +42,7 @@ 237 t->col = nil; 238 r1.min.y = r1.max.y; 239 r1.max.y += Border; 240 - draw(screen, r1, display->black, nil, ZP); 241 + draw(screen, r1, framecols[BORD], nil, ZP); 242 textinsert(t, 0, Lcolhdr, 29, TRUE); 243 textsetselect(t, t->file->b.nc, t->file->b.nc); 244 } 245 @@ -73,7 +73,7 @@ 246 r = d->r; 247 if(Dx(r) < 100) 248 return nil; 249 - draw(screen, r, display->white, nil, ZP); 250 + draw(screen, r, framecols[BACK], nil, ZP); 251 r1 = r; 252 r1.max.x = min(x-Border, r.max.x-50); 253 if(Dx(r1) < 50) 254 @@ -81,7 +81,7 @@ 255 colresize(d, r1); 256 r1.min.x = r1.max.x; 257 r1.max.x = r1.min.x+Border; 258 - draw(screen, r1, display->black, nil, ZP); 259 + draw(screen, r1, framecols[BORD], nil, ZP); 260 r.min.x = r1.max.x; 261 } 262 if(c == nil){ 263 @@ -115,7 +115,7 @@ 264 textresize(&row->tag, r1, TRUE); 265 r1.min.y = r1.max.y; 266 r1.max.y += Border; 267 - draw(screen, r1, display->black, nil, ZP); 268 + draw(screen, r1, framecols[BORD], nil, ZP); 269 r.min.y = r1.max.y; 270 r1 = r; 271 r1.max.x = r1.min.x; 272 @@ -130,7 +130,7 @@ 273 if(i > 0){ 274 r2 = r1; 275 r2.max.x = r2.min.x+Border; 276 - draw(screen, r2, display->black, nil, ZP); 277 + draw(screen, r2, framecols[BORD], nil, ZP); 278 r1.min.x = r2.max.x; 279 } 280 colresize(c, r1); 281 @@ -191,14 +191,14 @@ 282 p.x = c->r.max.x-80-Scrollwid; 283 r = d->r; 284 r.max.x = c->r.max.x; 285 - draw(screen, r, display->white, nil, ZP); 286 + draw(screen, r, framecols[BACK], nil, ZP); 287 r.max.x = p.x; 288 colresize(d, r); 289 r = c->r; 290 r.min.x = p.x; 291 r.max.x = r.min.x; 292 r.max.x += Border; 293 - draw(screen, r, display->black, nil, ZP); 294 + draw(screen, r, framecols[BORD], nil, ZP); 295 r.min.x = r.max.x; 296 r.max.x = c->r.max.x; 297 colresize(c, r); 298 @@ -223,7 +223,7 @@ 299 memmove(row->col+i, row->col+i+1, (row->ncol-i)*sizeof(Column*)); 300 row->col = realloc(row->col, row->ncol*sizeof(Column*)); 301 if(row->ncol == 0){ 302 - draw(screen, r, display->white, nil, ZP); 303 + draw(screen, r, framecols[BACK], nil, ZP); 304 return; 305 } 306 if(i == row->ncol){ /* extend last column right */ 307 @@ -234,7 +234,7 @@ 308 c = row->col[i]; 309 r.max.x = c->r.max.x; 310 } 311 - draw(screen, r, display->white, nil, ZP); 312 + draw(screen, r, framecols[BACK], nil, ZP); 313 colresize(c, r); 314 } 315 316 @@ -601,12 +601,12 @@ 317 r2.min.x = x; 318 if(Dx(r1) < 50 || Dx(r2) < 50) 319 continue; 320 - draw(screen, Rpt(r1.min, r2.max), display->white, nil, ZP); 321 + draw(screen, Rpt(r1.min, r2.max), framecols[BACK], nil, ZP); 322 colresize(c1, r1); 323 colresize(c2, r2); 324 r2.min.x = x-Border; 325 r2.max.x = x; 326 - draw(screen, r2, display->black, nil, ZP); 327 + draw(screen, r2, framecols[BORD], nil, ZP); 328 } 329 if(i >= row->ncol) 330 rowadd(row, nil, x); 331 diff -u a/src/cmd/acme/text.c b/src/cmd/acme/text.c 332 --- a/src/cmd/acme/text.c Sun Nov 10 21:20:26 2024 333 +++ b/src/cmd/acme/text.c Sun Nov 10 21:19:54 2024 334 @@ -694,8 +694,21 @@ 335 case Kdown: 336 if(t->what == Tag) 337 goto Tagdown; 338 - n = t->fr.maxlines/3; 339 - goto case_Down; 340 + typecommit(t); 341 + 342 + nb = n = 0; 343 + if ((nb = textbswidth(t, 0x15)) == 1) /* beginning of line */ 344 + nb = 0; 345 + for (q0 = t->q0; q0 < t->file->b.nc && textreadc(t, q0) != '\n'; q0++) 346 + ; 347 + while (++q0 < t->file->b.nc && textreadc(t, q0) != '\n') 348 + if (n++ == nb) 349 + break; 350 + q0 = q0 > t->file->b.nc ? t->file->b.nc : q0; 351 + 352 + textshow(t, q0, q0, TRUE); 353 + return; 354 + 355 case Kscrollonedown: 356 if(t->what == Tag) 357 goto Tagdown; 358 @@ -712,8 +725,18 @@ 359 case Kup: 360 if(t->what == Tag) 361 goto Tagup; 362 - n = t->fr.maxlines/3; 363 - goto case_Up; 364 + typecommit(t); 365 + 366 + nb = nnb = 0; 367 + for (q0 = t->q0; q0 > 0 && textreadc(t, q0-1) != '\n'; q0--) 368 + nb++; 369 + if (q0 > 0) 370 + for (--q0; q0 > 0 && textreadc(t, q0-1) != '\n'; q0--) 371 + nnb++; 372 + nb = nb > nnb ? nnb : nb; 373 + textshow(t, q0 + nb, q0 + nb, TRUE); 374 + 375 + return; 376 case Kscrolloneup: 377 if(t->what == Tag) 378 goto Tagup; 379 @@ -1258,7 +1281,7 @@ 380 }; 381 382 uint 383 -xselect(Frame *f, Mousectl *mc, Image *col, uint *p1p) /* when called, button is down */ 384 +xselect(Frame *f, Mousectl *mc, Image *bgcol, Image *fgcol, uint *p1p) /* when called, button is down */ 385 { 386 uint p0, p1, q, tmp; 387 ulong msec; 388 @@ -1291,12 +1314,12 @@ 389 pt1 = pt0; 390 reg = region(q, p0); 391 if(reg == 0) 392 - frdrawsel0(f, pt0, p0, p1, col, display->white); 393 + frdrawsel0(f, pt0, p0, p1, bgcol, fgcol); 394 } 395 qt = frptofchar(f, q); 396 if(reg > 0){ 397 if(q > p1) 398 - frdrawsel0(f, pt1, p1, q, col, display->white); 399 + frdrawsel0(f, pt1, p1, q, bgcol, fgcol); 400 401 else if(q < p1) 402 selrestore(f, qt, q, p1); 403 @@ -1304,7 +1327,7 @@ 404 if(q > p1) 405 selrestore(f, pt1, p1, q); 406 else 407 - frdrawsel0(f, qt, q, p1, col, display->white); 408 + frdrawsel0(f, qt, q, p1, bgcol, fgcol); 409 } 410 p1 = q; 411 pt1 = qt; 412 @@ -1341,12 +1364,12 @@ 413 } 414 415 int 416 -textselect23(Text *t, uint *q0, uint *q1, Image *high, int mask) 417 +textselect23(Text *t, uint *q0, uint *q1, Image *bgcol, Image *fgcol, int mask) 418 { 419 uint p0, p1; 420 int buts; 421 422 - p0 = xselect(&t->fr, mousectl, high, &p1); 423 + p0 = xselect(&t->fr, mousectl, bgcol, fgcol, &p1); 424 buts = mousectl->m.buttons; 425 if((buts & mask) == 0){ 426 *q0 = p0+t->org; 427 @@ -1364,7 +1387,7 @@ 428 int buts; 429 430 *tp = nil; 431 - buts = textselect23(t, q0, q1, but2col, 4); 432 + buts = textselect23(t, q0, q1, button2cols[BACK], button2cols[TEXT], 4); 433 if(buts & 4) 434 return 0; 435 if(buts & 1){ /* pick up argument */ 436 @@ -1379,7 +1402,7 @@ 437 { 438 int h; 439 440 - h = (textselect23(t, q0, q1, but3col, 1|2) == 0); 441 + h = (textselect23(t, q0, q1, button3cols[BACK], button3cols[TEXT], 1|2) == 0); 442 return h; 443 } 444 445 diff -u a/src/cmd/acme/wind.c b/src/cmd/acme/wind.c 446 --- a/src/cmd/acme/wind.c Sun Nov 10 21:20:26 2024 447 +++ b/src/cmd/acme/wind.c Sun Nov 10 21:19:54 2024 448 @@ -235,7 +235,6 @@ 449 r1.min.y = min(y, r.max.y); 450 r1.max.y = r.max.y; 451 }else{ 452 - draw(screen, r1, textcols[BACK], nil, ZP); 453 r1.min.y = y; 454 r1.max.y = y; 455 }