mirror of
https://github.com/urbit/shrub.git
synced 2024-12-20 09:21:42 +03:00
term: move coordinate origin to top left
Having the origin at the top left instead of the bottom left is more conventional and ergonomic. The only thing this complicates is prompt-specific logic, where we care about the coordinates of the bottom-most line on the screen. For that reason, the bulk of the changes here are in vere, where we treat the bottom-most line specially, drawing the spinner onto it. Webterm is likewise updated to account for the new coordinate system. Drum now opts to accept clicks anywhere on the screen, and does its best to move the cursor as close to the clicked location as possible (within the confines of the prompt).
This commit is contained in:
parent
c5b07f5203
commit
064b15e5a0
@ -687,10 +687,9 @@
|
|||||||
++ ta-hit :: hear click
|
++ ta-hit :: hear click
|
||||||
|= [x=@ud y=@ud]
|
|= [x=@ud y=@ud]
|
||||||
^+ +>
|
^+ +>
|
||||||
?. =(0 y) +>
|
|
||||||
=/ pol=@ud
|
=/ pol=@ud
|
||||||
(lent-char:klr (make:klr cad.pom))
|
(lent-char:klr (make:klr cad.pom))
|
||||||
?: (lth x pol) +>.$
|
=? x (lth x pol) pol
|
||||||
+>.$(pos.inp (min (sub x pol) (lent buf.say.inp)))
|
+>.$(pos.inp (min (sub x pol) (lent buf.say.inp)))
|
||||||
::
|
::
|
||||||
++ ta-erl :: hear local error
|
++ ta-erl :: hear local error
|
||||||
|
@ -90,7 +90,7 @@ const readInput = (term: Terminal, e: string): Belt[] => {
|
|||||||
if (1 === m) {
|
if (1 === m) {
|
||||||
const c = e.charCodeAt(2) - 32;
|
const c = e.charCodeAt(2) - 32;
|
||||||
const r = e.charCodeAt(3) - 32;
|
const r = e.charCodeAt(3) - 32;
|
||||||
belts.push({ hit: { y: term.rows - r, x: c - 1 } });
|
belts.push({ hit: { y: r - 1, x: c - 1 } });
|
||||||
}
|
}
|
||||||
e = e.slice(3);
|
e = e.slice(3);
|
||||||
break;
|
break;
|
||||||
|
@ -21,7 +21,7 @@ export const showBlit = (term: Terminal, blit: Blit) => {
|
|||||||
if (typeof blit.hop === 'number') {
|
if (typeof blit.hop === 'number') {
|
||||||
out += csi('H', term.rows, blit.hop + 1);
|
out += csi('H', term.rows, blit.hop + 1);
|
||||||
} else {
|
} else {
|
||||||
out += csi('H', term.rows - blit.hop.y, blit.hop.x + 1);
|
out += csi('H', blit.hop.y + 1, blit.hop.x + 1);
|
||||||
}
|
}
|
||||||
out += csi('s'); // save cursor position
|
out += csi('s'); // save cursor position
|
||||||
} else if ('put' in blit) {
|
} else if ('put' in blit) {
|
||||||
|
@ -385,7 +385,7 @@ _term_it_clear_line(u3_utty* uty_u)
|
|||||||
|
|
||||||
// if we're clearing the bottom line, clear our mirror of it too
|
// if we're clearing the bottom line, clear our mirror of it too
|
||||||
//
|
//
|
||||||
if ( 0 == uty_u->tat_u.mir.rus_w ) {
|
if ( uty_u->tat_u.siz.row_l - 1 == uty_u->tat_u.mir.rus_w ) {
|
||||||
_term_it_free_line(uty_u);
|
_term_it_free_line(uty_u);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -401,7 +401,7 @@ _term_it_show_blank(u3_utty* uty_u)
|
|||||||
|
|
||||||
/* _term_it_move_cursor(): move cursor to row & column
|
/* _term_it_move_cursor(): move cursor to row & column
|
||||||
*
|
*
|
||||||
* row 0 is at the bottom, col 0 is to the left.
|
* row 0 is at the top, col 0 is to the left.
|
||||||
* if the given position exceeds the known window size,
|
* if the given position exceeds the known window size,
|
||||||
* it is clipped to stay within the window.
|
* it is clipped to stay within the window.
|
||||||
*/
|
*/
|
||||||
@ -413,7 +413,7 @@ _term_it_move_cursor(u3_utty* uty_u, c3_w col_w, c3_w row_w)
|
|||||||
if ( row_w >= row_l ) { row_w = row_l - 1; }
|
if ( row_w >= row_l ) { row_w = row_l - 1; }
|
||||||
if ( col_w >= col_l ) { col_w = col_l - 1; }
|
if ( col_w >= col_l ) { col_w = col_l - 1; }
|
||||||
|
|
||||||
_term_it_send_csi(uty_u, 'H', 2, row_l - row_w, col_w + 1);
|
_term_it_send_csi(uty_u, 'H', 2, row_w + 1, col_w + 1);
|
||||||
_term_it_dump_buf(uty_u, &uty_u->ufo_u.suc_u);
|
_term_it_dump_buf(uty_u, &uty_u->ufo_u.suc_u);
|
||||||
|
|
||||||
uty_u->tat_u.mir.rus_w = row_w;
|
uty_u->tat_u.mir.rus_w = row_w;
|
||||||
@ -473,7 +473,7 @@ _term_it_restore_line(u3_utty* uty_u)
|
|||||||
{
|
{
|
||||||
u3_utat* tat_u = &uty_u->tat_u;
|
u3_utat* tat_u = &uty_u->tat_u;
|
||||||
|
|
||||||
_term_it_send_csi(uty_u, 'H', 2, tat_u->siz.row_l, 0);
|
_term_it_send_csi(uty_u, 'H', 2, tat_u->siz.row_l, 1);
|
||||||
_term_it_dump_buf(uty_u, &uty_u->ufo_u.cel_u);
|
_term_it_dump_buf(uty_u, &uty_u->ufo_u.cel_u);
|
||||||
_term_it_send_stub(uty_u, u3k(tat_u->mir.lin));
|
_term_it_send_stub(uty_u, u3k(tat_u->mir.lin));
|
||||||
//NOTE send_stub restores cursor position
|
//NOTE send_stub restores cursor position
|
||||||
@ -490,7 +490,8 @@ _term_it_save_stub(u3_utty* uty_u, u3_noun tub)
|
|||||||
// keep track of changes to bottom-most line, to aid spinner drawing logic.
|
// keep track of changes to bottom-most line, to aid spinner drawing logic.
|
||||||
// -t mode doesn't need this logic, because it doesn't render the spinner.
|
// -t mode doesn't need this logic, because it doesn't render the spinner.
|
||||||
//
|
//
|
||||||
if ( (0 == tat_u->mir.rus_w) && (c3n == u3_Host.ops_u.tem)) {
|
if ( ( tat_u->siz.row_l - 1 == tat_u->mir.rus_w ) &&
|
||||||
|
( c3n == u3_Host.ops_u.tem ) ) {
|
||||||
lin = u3dq("wail:klr:format", lin, tat_u->mir.cus_w, u3k(tub), ' ');
|
lin = u3dq("wail:klr:format", lin, tat_u->mir.cus_w, u3k(tub), ' ');
|
||||||
lin = u3do("pact:klr:format", lin);
|
lin = u3do("pact:klr:format", lin);
|
||||||
}
|
}
|
||||||
@ -513,8 +514,8 @@ _term_it_show_nel(u3_utty* uty_u)
|
|||||||
}
|
}
|
||||||
|
|
||||||
uty_u->tat_u.mir.cus_w = 0;
|
uty_u->tat_u.mir.cus_w = 0;
|
||||||
if ( uty_u->tat_u.mir.rus_w > 0 ) {
|
if ( uty_u->tat_u.mir.rus_w < uty_u->tat_u.siz.row_l - 1 ) {
|
||||||
uty_u->tat_u.mir.rus_w--;
|
uty_u->tat_u.mir.rus_w++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// newline at bottom of screen, so bottom line is now empty
|
// newline at bottom of screen, so bottom line is now empty
|
||||||
@ -716,11 +717,9 @@ _term_io_suck_char(u3_utty* uty_u, c3_y cay_y)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
c3_y row_y = cay_y - 32;
|
c3_y row_y = cay_y - 32;
|
||||||
// only acknowledge button 1 presses within our window
|
// only acknowledge button 1 presses within our known window
|
||||||
if ( 1 != tat_u->esc.ton_y && row_y <= tat_u->siz.row_l ) {
|
if ( 1 != tat_u->esc.ton_y && row_y <= tat_u->siz.row_l ) {
|
||||||
_term_io_spit(uty_u, u3nt(c3__hit,
|
_term_io_spit(uty_u, u3nt(c3__hit, tat_u->esc.col_y - 1, row_y - 1));
|
||||||
tat_u->esc.col_y - 1,
|
|
||||||
tat_u->siz.row_l - row_y));
|
|
||||||
}
|
}
|
||||||
tat_u->esc.mou = c3n;
|
tat_u->esc.mou = c3n;
|
||||||
tat_u->esc.ton_y = tat_u->esc.col_y = 0;
|
tat_u->esc.ton_y = tat_u->esc.col_y = 0;
|
||||||
@ -907,8 +906,8 @@ _term_spin_step(u3_utty* uty_u)
|
|||||||
// if we know where the bottom line is, and the cursor is not on it,
|
// if we know where the bottom line is, and the cursor is not on it,
|
||||||
// move it to the bottom left
|
// move it to the bottom left
|
||||||
//
|
//
|
||||||
if ( tat_u->siz.row_l && tat_u->mir.rus_w > 0 ) {
|
if ( tat_u->siz.row_l && tat_u->mir.rus_w < tat_u->siz.row_l - 1 ) {
|
||||||
_term_it_send_csi(uty_u, 'H', 2, tat_u->siz.row_l, 0);
|
_term_it_send_csi(uty_u, 'H', 2, tat_u->siz.row_l, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
c3_w i_w;
|
c3_w i_w;
|
||||||
@ -1357,7 +1356,7 @@ _term_ef_blit(u3_utty* uty_u,
|
|||||||
case c3__hop: {
|
case c3__hop: {
|
||||||
u3_noun pos = u3t(blt);
|
u3_noun pos = u3t(blt);
|
||||||
if ( c3y == u3r_ud(pos) ) {
|
if ( c3y == u3r_ud(pos) ) {
|
||||||
_term_it_move_cursor(uty_u, pos, 0);
|
_term_it_move_cursor(uty_u, pos, uty_u->tat_u.siz.row_l - 1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_term_it_move_cursor(uty_u, u3h(pos), u3t(pos));
|
_term_it_move_cursor(uty_u, u3h(pos), u3t(pos));
|
||||||
@ -1369,7 +1368,7 @@ _term_ef_blit(u3_utty* uty_u,
|
|||||||
} break;
|
} break;
|
||||||
|
|
||||||
case c3__lin: { //TMP backwards compatibility
|
case c3__lin: { //TMP backwards compatibility
|
||||||
_term_it_move_cursor(uty_u, 0, 0);
|
_term_it_move_cursor(uty_u, 0, uty_u->tat_u.siz.row_l - 1);
|
||||||
_term_it_clear_line(uty_u);
|
_term_it_clear_line(uty_u);
|
||||||
} //
|
} //
|
||||||
case c3__put: {
|
case c3__put: {
|
||||||
|
Loading…
Reference in New Issue
Block a user