Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.47 KB | None | 0 0
  1. 38d37
  2. < #define HISTSIZE 2000
  3. 46,51c45
  4. < #define ISDELIM(u) (u && wcschr(worddelimiters, u))
  5. < #define TLINE(y) ((y) < term.scr ? term.hist[((y) + term.histi - \
  6. < term.scr + HISTSIZE + 1) % HISTSIZE] : \
  7. < term.line[(y) - term.scr])
  8. <
  9. < #define TLINE_HIST(y) ((y) <= HISTSIZE-term.row+2 ? term.hist[(y)] : term.line[(y-HISTSIZE+term.row-3)])
  10. ---
  11. > #define ISDELIM(u) (utf8strchr(worddelimiters, u) != NULL)
  12. 130,132d123
  13. < Line hist[HISTSIZE]; /* history buffer */
  14. < int histi; /* history index */
  15. < int scr; /* scroll back */
  16. 200,201c191,192
  17. < static void tscrollup(int, int, int);
  18. < static void tscrolldown(int, int, int);
  19. ---
  20. > static void tscrollup(int, int);
  21. > static void tscrolldown(int, int);
  22. 225a217
  23. > static char *utf8strchr(char *, Rune);
  24. 267c259
  25. < void *p;
  26. ---
  27. > void *p = malloc(len);
  28. 269,270c261,262
  29. < if (!(p = malloc(len)))
  30. < die("malloc: %s\n", strerror(errno));
  31. ---
  32. > if (!p)
  33. > die("Out of memory\n");
  34. 279c271
  35. < die("realloc: %s\n", strerror(errno));
  36. ---
  37. > die("Out of memory\n");
  38. 288c280
  39. < die("strdup: %s\n", strerror(errno));
  40. ---
  41. > die("Out of memory\n");
  42. 351a344,360
  43. > char *
  44. > utf8strchr(char *s, Rune u)
  45. > {
  46. > Rune r;
  47. > size_t i, j, len;
  48. >
  49. > len = strlen(s);
  50. > for (i = 0, j = 0; i < len; i += j) {
  51. > if (!(j = utf8decode(&s[i], &r, len - i)))
  52. > break;
  53. > if (r == u)
  54. > return &(s[i]);
  55. > }
  56. >
  57. > return NULL;
  58. > }
  59. >
  60. 425c434
  61. < if (TLINE(y)[i - 1].mode & ATTR_WRAP)
  62. ---
  63. > if (term.line[y][i - 1].mode & ATTR_WRAP)
  64. 428,442c437
  65. < while (i > 0 && TLINE(y)[i - 1].u == ' ')
  66. < --i;
  67. <
  68. < return i;
  69. < }
  70. <
  71. < int
  72. < tlinehistlen(int y)
  73. < {
  74. < int i = term.col;
  75. <
  76. < if (TLINE_HIST(y)[i - 1].mode & ATTR_WRAP)
  77. < return i;
  78. <
  79. < while (i > 0 && TLINE_HIST(y)[i - 1].u == ' ')
  80. ---
  81. > while (i > 0 && term.line[y][i - 1].u == ' ')
  82. 454d448
  83. < sel.alt = IS_SET(MODE_ALTSCREEN);
  84. 482a477
  85. > sel.alt = IS_SET(MODE_ALTSCREEN);
  86. 488c483
  87. < if (oldey != sel.oe.y || oldex != sel.oe.x || oldtype != sel.type || sel.mode == SEL_EMPTY)
  88. ---
  89. > if (oldey != sel.oe.y || oldex != sel.oe.x || oldtype != sel.type)
  90. 551c546
  91. < prevgp = &TLINE(*y)[*x];
  92. ---
  93. > prevgp = &term.line[*y][*x];
  94. 566c561
  95. < if (!(TLINE(yt)[xt].mode & ATTR_WRAP))
  96. ---
  97. > if (!(term.line[yt][xt].mode & ATTR_WRAP))
  98. 573c568
  99. < gp = &TLINE(newy)[newx];
  100. ---
  101. > gp = &term.line[newy][newx];
  102. 594c589
  103. < if (!(TLINE(*y-1)[term.col-1].mode
  104. ---
  105. > if (!(term.line[*y-1][term.col-1].mode
  106. 601c596
  107. < if (!(TLINE(*y)[term.col-1].mode
  108. ---
  109. > if (!(term.line[*y][term.col-1].mode
  110. 632c627
  111. < gp = &TLINE(y)[sel.nb.x];
  112. ---
  113. > gp = &term.line[y][sel.nb.x];
  114. 635c630
  115. < gp = &TLINE(y)[sel.nb.y == y ? sel.nb.x : 0];
  116. ---
  117. > gp = &term.line[y][sel.nb.y == y ? sel.nb.x : 0];
  118. 638c633
  119. < last = &TLINE(y)[MIN(lastx, linelen-1)];
  120. ---
  121. > last = &term.line[y][MIN(lastx, linelen-1)];
  122. 695c690
  123. < die("getpwuid: %s\n", strerror(errno));
  124. ---
  125. > die("getpwuid:%s\n", strerror(errno));
  126. 738c733
  127. < die("waiting for pid %hd failed: %s\n", pid, strerror(errno));
  128. ---
  129. > die("Waiting for pid %hd failed: %s\n", pid, strerror(errno));
  130. 743,746c738,739
  131. < if (WIFEXITED(stat) && WEXITSTATUS(stat))
  132. < die("child exited with status %d\n", WEXITSTATUS(stat));
  133. < else if (WIFSIGNALED(stat))
  134. < die("child terminated due to signal %d\n", WTERMSIG(stat));
  135. ---
  136. > if (!WIFEXITED(stat) || WEXITSTATUS(stat))
  137. > die("child finished with error '%d'\n", stat);
  138. 791,792c784
  139. < die("open line '%s' failed: %s\n",
  140. < line, strerror(errno));
  141. ---
  142. > die("open line failed: %s\n", strerror(errno));
  143. 804c796
  144. < die("fork failed: %s\n", strerror(errno));
  145. ---
  146. > die("fork failed\n");
  147. 816,819d807
  148. < #ifdef __OpenBSD__
  149. < if (pledge("stdio getpw proc exec", NULL) == -1)
  150. < die("pledge\n");
  151. < #endif
  152. 823,826d810
  153. < #ifdef __OpenBSD__
  154. < if (pledge("stdio rpath tty proc", NULL) == -1)
  155. < die("pledge\n");
  156. < #endif
  157. 845c829
  158. < die("couldn't read from shell: %s\n", strerror(errno));
  159. ---
  160. > die("Couldn't read from shell: %s\n", strerror(errno));
  161. 861,863d844
  162. < Arg arg = (Arg) { .i = term.scr };
  163. <
  164. < kscrolldown(&arg);
  165. 1075,1108c1056
  166. < kscrolldown(const Arg* a)
  167. < {
  168. < int n = a->i;
  169. <
  170. < if (n < 0)
  171. < n = term.row + n;
  172. <
  173. < if (n > term.scr)
  174. < n = term.scr;
  175. <
  176. < if (term.scr > 0) {
  177. < term.scr -= n;
  178. < selscroll(0, -n);
  179. < tfulldirt();
  180. < }
  181. < }
  182. <
  183. < void
  184. < kscrollup(const Arg* a)
  185. < {
  186. < int n = a->i;
  187. <
  188. < if (n < 0)
  189. < n = term.row + n;
  190. <
  191. < if (term.scr <= HISTSIZE-n) {
  192. < term.scr += n;
  193. < selscroll(0, n);
  194. < tfulldirt();
  195. < }
  196. < }
  197. <
  198. < void
  199. < tscrolldown(int orig, int n, int copyhist)
  200. ---
  201. > tscrolldown(int orig, int n)
  202. 1115,1121d1062
  203. < if (copyhist) {
  204. < term.histi = (term.histi - 1 + HISTSIZE) % HISTSIZE;
  205. < temp = term.hist[term.histi];
  206. < term.hist[term.histi] = term.line[term.bot];
  207. < term.line[term.bot] = temp;
  208. < }
  209. <
  210. 1135c1076
  211. < tscrollup(int orig, int n, int copyhist)
  212. ---
  213. > tscrollup(int orig, int n)
  214. 1142,1151d1082
  215. < if (copyhist) {
  216. < term.histi = (term.histi + 1) % HISTSIZE;
  217. < temp = term.hist[term.histi];
  218. < term.hist[term.histi] = term.line[orig];
  219. < term.line[orig] = temp;
  220. < }
  221. <
  222. < if (term.scr > 0 && term.scr < HISTSIZE)
  223. < term.scr = MIN(term.scr + n, HISTSIZE-1);
  224. <
  225. 1200c1131
  226. < tscrollup(term.top, 1, 1);
  227. ---
  228. > tscrollup(term.top, 1);
  229. 1365c1296
  230. < tscrolldown(term.c.y, n, 0);
  231. ---
  232. > tscrolldown(term.c.y, n);
  233. 1372c1303
  234. < tscrollup(term.c.y, n, 0);
  235. ---
  236. > tscrollup(term.c.y, n);
  237. 1519,1520c1450
  238. < attr[i]);
  239. < csidump();
  240. ---
  241. > attr[i]), csidump();
  242. 1640d1569
  243. < break;
  244. 1803c1732
  245. < tscrollup(term.top, csiescseq.arg[0], 0);
  246. ---
  247. > tscrollup(term.top, csiescseq.arg[0]);
  248. 1807c1736
  249. < tscrolldown(term.top, csiescseq.arg[0], 0);
  250. ---
  251. > tscrolldown(term.top, csiescseq.arg[0]);
  252. 1912c1841
  253. < char *p = NULL, *dec;
  254. ---
  255. > char *p = NULL;
  256. 1929a1859,1860
  257. > char *dec;
  258. >
  259. 1947,1950c1878
  260. < if (par == 104 && narg <= 1)
  261. < return; /* color reset without parameter */
  262. < fprintf(stderr, "erresc: invalid color j=%d, p=%s\n",
  263. < j, p ? p : "(null)");
  264. ---
  265. > fprintf(stderr, "erresc: invalid color %s\n", p);
  266. 2048,2103d1975
  267. < externalpipe(const Arg *arg)
  268. < {
  269. < int to[2];
  270. < char buf[UTF_SIZ];
  271. < void (*oldsigpipe)(int);
  272. < Glyph *bp, *end;
  273. < int lastpos, n, newline;
  274. <
  275. < if (pipe(to) == -1)
  276. < return;
  277. <
  278. < switch (fork()) {
  279. < case -1:
  280. < close(to[0]);
  281. < close(to[1]);
  282. < return;
  283. < case 0:
  284. < dup2(to[0], STDIN_FILENO);
  285. < close(to[0]);
  286. < close(to[1]);
  287. < execvp(((char **)arg->v)[0], (char **)arg->v);
  288. < fprintf(stderr, "st: execvp %s\n", ((char **)arg->v)[0]);
  289. < perror("failed");
  290. < exit(0);
  291. < }
  292. <
  293. < close(to[0]);
  294. < /* ignore sigpipe for now, in case child exists early */
  295. < oldsigpipe = signal(SIGPIPE, SIG_IGN);
  296. < newline = 0;
  297. < /* modify externalpipe patch to pipe history too */
  298. < for (n = 0; n <= HISTSIZE + 2; n++) {
  299. < bp = TLINE_HIST(n);
  300. < lastpos = MIN(tlinehistlen(n) +1, term.col) - 1;
  301. < if (lastpos < 0)
  302. < break;
  303. < if (lastpos == 0)
  304. < continue;
  305. < end = &bp[lastpos + 1];
  306. < for (; bp < end; ++bp)
  307. < if (xwrite(to[1], buf, utf8encode(bp->u, buf)) < 0)
  308. < break;
  309. < if ((newline = TLINE_HIST(n)[lastpos].mode & ATTR_WRAP))
  310. < continue;
  311. < if (xwrite(to[1], "\n", 1) < 0)
  312. < break;
  313. < newline = 0;
  314. < }
  315. < if (newline)
  316. < (void)xwrite(to[1], "\n", 1);
  317. < close(to[1]);
  318. < /* restore */
  319. < signal(SIGPIPE, oldsigpipe);
  320. < }
  321. <
  322. < void
  323. 2388c2260
  324. < tscrollup(term.top, 1, 1);
  325. ---
  326. > tscrollup(term.top, 1);
  327. 2401c2273
  328. < tscrolldown(term.top, 1, 1);
  329. ---
  330. > tscrolldown(term.top, 1);
  331. 2409c2281
  332. < case 'c': /* RIS -- Reset to initial state */
  333. ---
  334. > case 'c': /* RIS -- Reset to inital state */
  335. 2479a2352
  336. >
  337. 2619c2492
  338. < int i, j;
  339. ---
  340. > int i;
  341. 2656,2663d2528
  342. < for (i = 0; i < HISTSIZE; i++) {
  343. < term.hist[i] = xrealloc(term.hist[i], col * sizeof(Glyph));
  344. < for (j = mincol; j < col; j++) {
  345. < term.hist[i][j] = term.c.attr;
  346. < term.hist[i][j].u = ' ';
  347. < }
  348. < }
  349. <
  350. 2721c2586
  351. < xdrawline(TLINE(y), x1, y, x2);
  352. ---
  353. > xdrawline(term.line[y], x1, y, x2);
  354. 2742,2744c2607,2608
  355. < if (term.scr == 0)
  356. < xdrawcursor(cx, term.c.y, term.line[term.c.y][cx],
  357. < term.ocx, term.ocy, term.line[term.ocy][term.ocx]);
  358. ---
  359. > xdrawcursor(cx, term.c.y, term.line[term.c.y][cx],
  360. > term.ocx, term.ocy, term.line[term.ocy][term.ocx]);
  361. 2747d2610
  362. < xximspot(term.ocx, term.ocy);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement