Un outil pour réarranger les lignes de stdin - retour accueil
git clone git://bebou.netlib.re/reorder
Log | Files | Refs | README |
commit 1389c2d50d6df2c61744a8eda828155e32ed865b parent 0bca3679c889ac58554476af97a09845927783aa Auteurice: Arthur Pons <arthur.pons@unistra.fr> Date: Fri, 17 Jan 2025 12:42:42 +0100 L'affichage dans une fonction dédiée Diffstat:
M | reorder.c | | | 52 | ++++++++++++++++++++++++++++------------------------ |
1 file changed, 28 insertions(+), 24 deletions(-)
diff --git a/reorder.c b/reorder.c @@ -40,6 +40,33 @@ struct pile file2pile(FILE *fp) { return pi; } +void display(struct pile* h, struct pile* p, int curline, char* curmenu,bool selection) { + tb_clear(); + int i; int j; + for (i=0;i<h->cardCount;i++) { + if (i==curline && curmenu=="hand") { + if (selection) { + tb_printf(0, i, TB_BLACK, TB_BLUE, h->cards[i]); + } else { + tb_printf(0, i, TB_BLACK, TB_WHITE, h->cards[i]); + } + } + else { tb_printf(0, i, TB_DEFAULT, TB_BLACK, h->cards[i]); } + } + tb_printf(0, i, TB_DEFAULT, TB_BLACK, "------"); + for (j=0;j<p->cardCount;j++) { + if (j==curline && curmenu=="played") { + if (selection) { + tb_printf(0, i+j+1, TB_BLACK, TB_BLUE, p->cards[j]); + } else { + tb_printf(0, i+j+1, TB_BLACK, TB_WHITE, p->cards[j]); + } + } + else { tb_printf(0, i+j+1, TB_DEFAULT, TB_BLACK, p->cards[j]); } + } + tb_present(); +} + int main(int argc, char **argv) { struct tb_event ev; int curline = 0; @@ -59,30 +86,7 @@ int main(int argc, char **argv) { char* curmenu="hand"; while(quit) { - tb_clear(); - int i; int j; - for (i=0;i<hand.cardCount;i++) { - if (i==curline && curmenu=="hand") { - if (selection) { - tb_printf(0, i, TB_BLACK, TB_BLUE, hand.cards[i]); - } else { - tb_printf(0, i, TB_BLACK, TB_WHITE, hand.cards[i]); - } - } - else { tb_printf(0, i, TB_DEFAULT, TB_BLACK, hand.cards[i]); } - } - tb_printf(0, i, TB_DEFAULT, TB_BLACK, "------"); - for (j=0;j<played.cardCount;j++) { - if (j==curline && curmenu=="played") { - if (selection) { - tb_printf(0, i+j+1, TB_BLACK, TB_BLUE, played.cards[j]); - } else { - tb_printf(0, i+j+1, TB_BLACK, TB_WHITE, played.cards[j]); - } - } - else { tb_printf(0, i+j+1, TB_DEFAULT, TB_BLACK, played.cards[j]); } - } - tb_present(); + display(h,p,curline,curmenu,selection); tb_poll_event(&ev); switch(ev.key) { /* up */