this repo has no description
13
fork

Configure Feed

Select the types of activity you want to include in your feed.

widgets(terminal): implement many more CSI seqs

+134 -6
+62 -1
src/widgets/terminal/Screen.zig
··· 368 368 } 369 369 } 370 370 371 - /// delete n lines from te bottom of te scrolling region 371 + pub fn eraseLeft(self: *Screen) void { 372 + self.cursor.pending_wrap = false; 373 + const start = self.cursor.row * self.width; 374 + const end = start + self.cursor.col; 375 + var i = start; 376 + while (i < end) : (i += 1) { 377 + self.buf[i].erase(self.cursor.style.bg); 378 + } 379 + } 380 + 381 + pub fn eraseLine(self: *Screen) void { 382 + self.cursor.pending_wrap = false; 383 + const start = self.cursor.row * self.width; 384 + const end = start + self.width; 385 + var i = start; 386 + while (i < end) : (i += 1) { 387 + self.buf[i].erase(self.cursor.style.bg); 388 + } 389 + } 390 + 391 + /// delete n lines from the bottom of the scrolling region 372 392 pub fn deleteLine(self: *Screen, n: usize) !void { 373 393 if (n == 0) return; 374 394 ··· 419 439 } 420 440 } 421 441 } 442 + 443 + pub fn eraseBelow(self: *Screen) void { 444 + self.eraseRight(); 445 + // start is the first column of the row below us 446 + const start = (self.cursor.row * self.width) + (self.width); 447 + var i = start; 448 + while (i < self.buf.len) : (i += 1) { 449 + self.buf[i].erase(self.cursor.style.bg); 450 + } 451 + } 452 + 453 + pub fn eraseAbove(self: *Screen) void { 454 + self.eraseLeft(); 455 + // start is the first column of the row below us 456 + const start: usize = 0; 457 + const end = self.cursor.row * self.width; 458 + var i = start; 459 + while (i < end) : (i += 1) { 460 + self.buf[i].erase(self.cursor.style.bg); 461 + } 462 + } 463 + 464 + pub fn eraseAll(self: *Screen) void { 465 + var i: usize = 0; 466 + while (i < self.buf.len) : (i += 1) { 467 + self.buf[i].erase(self.cursor.style.bg); 468 + } 469 + } 470 + 471 + pub fn deleteCharacters(self: *Screen, n: usize) !void { 472 + if (!self.withinScrollingRegion()) return; 473 + 474 + self.cursor.pending_wrap = false; 475 + var col = self.cursor.col; 476 + while (col <= self.scrolling_region.right) : (col += 1) { 477 + if (col + n <= self.scrolling_region.right) 478 + try self.buf[col].copyFrom(self.buf[col + n]) 479 + else 480 + self.buf[col].erase(self.cursor.style.bg); 481 + } 482 + }
+72 -5
src/widgets/terminal/Terminal.zig
··· 332 332 var iter = seq.iterator(u16); 333 333 const kind = iter.next() orelse 0; 334 334 switch (kind) { 335 - 0 => {}, 336 - 1 => {}, 337 - 2 => {}, 335 + 0 => self.back_screen.eraseBelow(), 336 + 1 => self.back_screen.eraseAbove(), 337 + 2 => self.back_screen.eraseAll(), 338 338 3 => {}, 339 339 else => {}, 340 340 } ··· 346 346 const ps = iter.next() orelse 0; 347 347 switch (ps) { 348 348 0 => self.back_screen.eraseRight(), 349 - 1 => {}, 350 - 2 => {}, 349 + 1 => self.back_screen.eraseLeft(), 350 + 2 => self.back_screen.eraseLine(), 351 351 else => continue, 352 352 } 353 353 }, 354 + // Insert Lines 354 355 'L' => { 355 356 var iter = seq.iterator(u16); 356 357 const n = iter.next() orelse 1; 357 358 try self.back_screen.insertLine(n); 358 359 }, 360 + // Delete Lines 359 361 'M' => { 360 362 var iter = seq.iterator(u16); 361 363 const n = iter.next() orelse 1; 362 364 try self.back_screen.deleteLine(n); 365 + }, 366 + // Delete Character 367 + 'P' => { 368 + var iter = seq.iterator(u16); 369 + const n = iter.next() orelse 1; 370 + try self.back_screen.deleteCharacters(n); 371 + }, 372 + // Scroll Up 373 + 'S' => { 374 + var iter = seq.iterator(u16); 375 + const n = iter.next() orelse 1; 376 + const cur_row = self.back_screen.cursor.row; 377 + const cur_col = self.back_screen.cursor.col; 378 + const wrap = self.back_screen.cursor.pending_wrap; 379 + defer { 380 + self.back_screen.cursor.row = cur_row; 381 + self.back_screen.cursor.col = cur_col; 382 + self.back_screen.cursor.pending_wrap = wrap; 383 + } 384 + self.back_screen.cursor.col = self.back_screen.scrolling_region.left; 385 + self.back_screen.cursor.row = self.back_screen.scrolling_region.top; 386 + try self.back_screen.deleteLine(n); 387 + }, 388 + // Scroll Down 389 + 'T' => { 390 + var iter = seq.iterator(u16); 391 + const n = iter.next() orelse 1; 392 + const cur_row = self.back_screen.cursor.row; 393 + const cur_col = self.back_screen.cursor.col; 394 + const wrap = self.back_screen.cursor.pending_wrap; 395 + defer { 396 + self.back_screen.cursor.row = cur_row; 397 + self.back_screen.cursor.col = cur_col; 398 + self.back_screen.cursor.pending_wrap = wrap; 399 + } 400 + self.back_screen.cursor.col = self.back_screen.scrolling_region.left; 401 + self.back_screen.cursor.row = self.back_screen.scrolling_region.top; 402 + try self.back_screen.insertLine(n); 403 + }, 404 + 'W' => {}, // TODO: Tab control 405 + 'X' => { 406 + self.back_screen.cursor.pending_wrap = false; 407 + var iter = seq.iterator(u16); 408 + const n = iter.next() orelse 1; 409 + const start = self.back_screen.cursor.row * self.back_screen.width + self.back_screen.cursor.col; 410 + const end = @max( 411 + self.back_screen.cursor.row * self.back_screen.width + self.back_screen.width, 412 + n, 413 + ); 414 + var i: usize = start; 415 + while (i < end) : (i += 1) { 416 + self.back_screen.buf[i].erase(self.back_screen.cursor.style.bg); 417 + } 418 + }, 419 + 'Z' => {}, // TODO: Back tab 420 + // 421 + // Cursor Vertial Position Aboslute 422 + 'd' => { 423 + var iter = seq.iterator(u16); 424 + const n = iter.next() orelse 1; 425 + self.back_screen.cursor.pending_wrap = false; 426 + self.back_screen.cursor.row = @min( 427 + self.back_screen.height -| 1, 428 + n -| 1, 429 + ); 363 430 }, 364 431 'h', 'l' => { 365 432 var iter = seq.iterator(u16);