mojibake: fix some row overruns #842

pull/848/head
nick black 4 years ago committed by Nick Black
parent ca6ecf2f35
commit 2dcab374c4

@ -712,12 +712,14 @@ ncplane_resize_simple(struct ncplane* n, int ylen, int xlen){
return ncplane_resize(n, 0, 0, keepleny, keeplenx, 0, 0, ylen, xlen);
}
// Move this plane relative to the standard plane. It is an error to attempt to
// move the standard plane.
// Move this plane relative to the standard plane, or the plane to which it is
// bound (if it is bound to a plane). It is an error to attempt to move the
// standard plane.
int ncplane_move_yx(struct ncplane* n, int y, int x);
// Get the origin of this ncplane relative to the standard plane.
void ncplane_yx(struct ncplane* n, int* restrict y, int* restrict x);
// Get the origin of this plane relative to the standard plane, or the plane to
// which it is bound (if it is bound to a plane).
void ncplane_yx(const struct ncplane* n, int* restrict y, int* restrict x);
// Return the dimensions of this ncplane.
void ncplane_dim_yx(struct ncplane* n, int* restrict rows, int* restrict cols);

@ -159,7 +159,10 @@ anywhere. In addition to its framebuffer--a rectilinear matrix of cells
* a current style, foreground channel, and background channel,
* its geometry,
* a configured user pointer,
* its position relative to the visible plane, and
* position relative to the standard plane,
* the plane, if any, to which it is bound,
* the next plane bound by the plane to which it is bound,
* the head of the list of its bound planes, and
* its z-index.
New planes can be created with **ncplane_new**, **ncplane_bound**, and

@ -1212,11 +1212,13 @@ API int ncplane_set_base(struct ncplane* ncp, const char* egc,
// 'ncp' is destroyed.
API int ncplane_base(struct ncplane* ncp, cell* c);
// Move this plane relative to the standard plane. It is an error to attempt to
// move the standard plane.
// Move this plane relative to the standard plane, or the plane to which it is
// bound (if it is bound to a plane). It is an error to attempt to move the
// standard plane.
API int ncplane_move_yx(struct ncplane* n, int y, int x);
// Get the origin of this plane relative to the standard plane.
// Get the origin of this plane relative to the standard plane, or the plane to
// which it is bound (if it is bound to a plane).
API void ncplane_yx(const struct ncplane* n, int* RESTRICT y, int* RESTRICT x);
// Splice ncplane 'n' out of the z-buffer, and reinsert it at the top or bottom.

@ -3465,34 +3465,35 @@ unicode52(struct ncplane* title, int y){
static struct ncplane*
unicode60(struct ncplane* title, int y){
const char SUMMARY[] = "[Unicode 6.0 (2010), 722 codepoints]";
const int ROWS = 25;
const int ROWS = 26;
struct ncplane* n = mojiplane(title, y, ROWS, SUMMARY);
if(n == NULL){
return NULL;
}
ncplane_putstr_yx(n, 1, 1, "😃😄😁😆😅😂😉😊😇😍😘😚😋😜😝😐😶😏😒😌😔😪😷😵😎😲😳😨😰😥😢😭");
ncplane_putstr_yx(n, 2, 1, "😱😖😣😞😓😩😫😤😡😠😈👿💀💩👹👺👻👽👾😺😸😹😻😼😽🙀😿😾🙈🙉🙊💋");
ncplane_putstr_yx(n, 3, 1, "💌💘💝💖💗💓💞💕💟💔💛💚💙💜💯💢💥💫💦💨💣💬💭💤👋✋👌👈👉👆👇👍");
ncplane_putstr_yx(n, 4, 1, "👎✊👊👏🙌👐🙏💅💪👂👃👀👅👄👶👦👧👱👨👩👴👵🙍🙎🙅🙆💁🙋🙇👮💂👷");
ncplane_putstr_yx(n, 5, 1, "👸👳👲👰👼🎅💆💇🚶🏃💃👯🏇🏂🏄🚣🏊🚴🚵🛀👭👫👬💏💑👪👤👥👣🐵🐒🐶");
ncplane_putstr_yx(n, 6, 1, "🐕🐩🐺🐱🐈🐯🐅🐆🐴🐎🐮🐂🐃🐄🐷🐖🐗🐽🐏🐑🐐🐪🐫🐘🐭🐁🐀🐹🐰🐇🐻🐨");
ncplane_putstr_yx(n, 7, 1, "🐼🐾🐔🐓🐣🐤🐥🐦🐧🐸🐊🐢🐍🐲🐉🐳🐋🐬🐟🐠🐡🐙🐚🐌🐛🐜🐝🐞💐🌸💮🌹");
ncplane_putstr_yx(n, 8, 1, "🌺🌻🌼🌷🌱🌲🌳🌴🌵🌾🌿🍀🍁🍂🍃🍇🍈🍉🍊🍋🍌🍍🍎🍏🍐🍑🍒🍓🍅🍆🌽🍄");
ncplane_putstr_yx(n, 9, 1, "🌰🍞🍖🍗🍔🍟🍕🍳🍲🍱🍘🍙🍚🍛🍜🍝🍠🍢🍣🍤🍥🍡🍦🍧🍨🍩🍪🎂🍰🍫🍬🍭");
ncplane_putstr_yx(n, 10, 1, "🍮🍯🍼🍵🍶🍷🍸🍹🍺🍻🍴🔪🌍🌎🌏🌐🗾🌋🗻🏠🏡🏢🏣🏤🏥🏦🏨🏩🏪🏫🏬🏭");
ncplane_putstr_yx(n, 11, 1, "🏯🏰💒🗼🗽🌁🌃🌄🌅🌆🌇🌉🎠🎡🎢💈🎪🚂🚃🚄🚅🚆🚇🚈🚉🚊🚝🚞🚋🚌🚍🚎");
ncplane_putstr_yx(n, 12, 1, "🚐🚑🚒🚓🚔🚕🚖🚗🚘🚙🚚🚛🚜🚲🚏🚨🚥🚦🚧🚤🚢💺🚁🚟🚠🚡🚀⏳⏰⏱⏲🕛🕧");
ncplane_putstr_yx(n, 13, 1, "🕐🕜🕑🕝🕒🕞🕓🕟🕔🕠🕕🕡🕖🕢🕗🕣🕘🕤🕙🕥🕚🕦🌑🌒🌓🌔🌕🌖🌗🌘🌙🌚");
ncplane_putstr_yx(n, 14, 1, "🌛🌜🌝🌞🌟🌠🌌🌀🌈🌂🔥💧🌊🎃🎄🎆🎇✨🎈🎉🎊🎋🎍🎎🎏🎐🎑🎀🎁🎫🏆🏀");
ncplane_putstr_yx(n, 15, 1, "🏈🏉🎾🎳🎣🎽🎿🎯🎱🔮🎮🎰🎲🃏🎴🎭🎨👓👔👕👖👗👘👙👚👛👜👝🎒👞👟👠");
ncplane_putstr_yx(n, 16, 1, "👡👢👑👒🎩🎓💄💍💎🔇🔈🔉🔊📢📣📯🔔🔕🎼🎵🎶🎤🎧📻🎷🎸🎹🎺🎻📱📲📞");
ncplane_putstr_yx(n, 17, 1, "📟📠🔋🔌💻💽💾💿📀🎥🎬📺📷📹📼🔍🔎💡🔦🏮📔📕📖📗📘📙📚📓📒📃📜📄");
ncplane_putstr_yx(n, 18, 1, "📰📑🔖💰💴💵💶💷💸💳💹📧📨📩📤📥📦📫📪📬📭📮📝💼📁📂📅📆📇📈📉📊");
ncplane_putstr_yx(n, 19, 1, "📋📌📍📎📏📐🔒🔓🔏🔐🔑🔨🔫🔧🔩🔗🔬🔭📡💉💊🚪🚽🚿🛁🚬🗿🏧🚮🚰🚹🚺");
ncplane_putstr_yx(n, 20, 1, "🚻🚼🚾🛂🛃🛄🛅🚸🚫🚳🚭🚯🚱🚷📵🔞🔃🔄🔙🔚🔛🔜🔝🔯⛎🔀🔁🔂⏩🔼⏪");
ncplane_putstr_yx(n, 21, 1, "\ufe0f\ufe0f⏫🔽⏬🎦🔅🔆📶📳📴➕➖➗❓❔❕💱💲🔱📛🔰✅❌❎➰➿🔟🔠🔡🔢");
ncplane_putstr_yx(n, 22, 1, "\ufe0f🔣🔤🅰🆎🅱🆑🆒🆓🆔🆕🆖🅾🆗🆘🆙🆚🈁🈂🈷🈶🉐🈹🈲🉑🈸🈴🈳🈺🈵🔴🔵🔶🔷");
ncplane_putstr_yx(n, 23, 1, "🔸🔹🔺🔻💠🔘🔳🔲🏁🚩🎌⛧⛤⛢⛦⛥");
ncplane_putstr_yx(n, 1, 1, "😃😄😁😆😅😂😉😊😇😍😘😚😋😜😝😐😶😏😒😌😔😪😷😵😎😲😳😨😰😥😢");
ncplane_putstr_yx(n, 2, 1, "😭😱😖😣😞😓😩😫😤😡😠😈👿💀💩👹👺👻👽👾😺😸😹😻😼😽🙀😿😾🙈🙉");
ncplane_putstr_yx(n, 3, 1, "🙊💋💌💘💝💖💗💓💞💕💟💔💛💚💙💜💯💢💥💫💦💨💣💬💭💤👋✋👌👈👉");
ncplane_putstr_yx(n, 4, 1, "👆👇👍👎✊👊👏🙌👐🙏💅💪👂👃👀👅👄👶👦👧👱👨👩👴👵🙍🙎🙅🙆💁🙋");
ncplane_putstr_yx(n, 5, 1, "🙇👮💂👷👸👳👲👰👼🎅💆💇🚶🏃💃👯🏇🏂🏄🚣🏊🚴🚵🛀👭👫👬💏💑👪👤");
ncplane_putstr_yx(n, 6, 1, "👥👣🐵🐒🐶🐕🐩🐺🐱🐈🐯🐅🐆🐴🐎🐮🐂🐃🐄🐷🐖🐗🐽🐏🐑🐐🐪🐫🐘🐭🐁");
ncplane_putstr_yx(n, 7, 1, "🐀🐹🐰🐇🐻🐨🐼🐾🐔🐓🐣🐤🐥🐦🐧🐸🐊🐢🐍🐲🐉🐳🐋🐬🐟🐠🐡🐙🐚🐌🐛");
ncplane_putstr_yx(n, 8, 1, "🐜🐝🐞💐🌸💮🌹🌺🌻🌼🌷🌱🌲🌳🌴🌵🌾🌿🍀🍁🍂🍃🍇🍈🍉🍊🍋🍌🍍🍎🍏");
ncplane_putstr_yx(n, 9, 1, "🍐🍑🍒🍓🍅🍆🌽🍄🌰🍞🍖🍗🍔🍟🍕🍳🍲🍱🍘🍙🍚🍛🍜🍝🍠🍢🍣🍤🍥🍡🍦");
ncplane_putstr_yx(n, 10, 1, "🍧🍨🍩🍪🎂🍰🍫🍬🍭🍮🍯🍼🍵🍶🍷🍸🍹🍺🍻🍴🔪🌍🌎🌏🌐🗾🌋🗻🏠🏡🏢");
ncplane_putstr_yx(n, 11, 1, "🏣🏤🏥🏦🏨🏩🏪🏫🏬🏭🏯🏰💒🗼🗽🌁🌃🌄🌅🌆🌇🌉🎠🎡🎢💈🎪🚂🚃🚄🚅");
ncplane_putstr_yx(n, 12, 1, "🚆🚇🚈🚉🚊🚝🚞🚋🚌🚍🚎🚐🚑🚒🚓🚔🚕🚖🚗🚘🚙🚚🚛🚜🚲🚏🚨🚥🚦🚧🚤");
ncplane_putstr_yx(n, 13, 1, "🚢💺🚁🚟🚠🚡🚀⏳⏰⏱⏲🕛🕧🕐🕜🕑🕝🕒🕞🕓🕟🕔🕠🕕🕡🕖🕢🕗🕣🕘🕤🕙");
ncplane_putstr_yx(n, 14, 1, "🕥🕚🕦🌑🌒🌓🌔🌕🌖🌗🌘🌙🌚🌛🌜🌝🌞🌟🌠🌌🌀🌈🌂🔥💧🌊🎃🎄🎆🎇✨");
ncplane_putstr_yx(n, 15, 1, "🎈🎉🎊🎋🎍🎎🎏🎐🎑🎀🎁🎫🏆🏀🏈🏉🎾🎳🎣🎽🎿🎯🎱🔮🎮🎰🎲🃏🎴🎭🎨");
ncplane_putstr_yx(n, 16, 1, "👓👔👕👖👗👘👙👚👛👜👝🎒👞👟👠👡👢👑👒🎩🎓💄💍💎🔇🔈🔉🔊📢📣📯");
ncplane_putstr_yx(n, 17, 1, "🔔🔕🎼🎵🎶🎤🎧📻🎷🎸🎹🎺🎻📱📲📞📟📠🔋🔌💻💽💾💿📀🎥🎬📺📷📹📼");
ncplane_putstr_yx(n, 18, 1, "🔍🔎💡🔦🏮📔📕📖📗📘📙📚📓📒📃📜📄📰📑🔖💰💴💵💶💷💸💳💹📧📨📩");
ncplane_putstr_yx(n, 19, 1, "📤📥📦📫📪📬📭📮📝💼📁📂📅📆📇📈📉📊📋📌📍📎📏📐🔒🔓🔏🔐🔑🔨🔫");
ncplane_putstr_yx(n, 20, 1, "🔧🔩🔗🔬🔭📡💉💊🚪🚽🚿🛁🚬🗿🏧🚮🚰🚹🚺🚻🚼🚾🛂🛃🛄🛅🚸🚫🚳🚭🚯");
ncplane_putstr_yx(n, 21, 1, "🚱🚷📵🔞🔃🔄🔙🔚🔛🔜🔝🔯⛎🔀🔁🔂⏩🔼⏪⏭\ufe0f\ufe0f⏫🔽⏬🎦🔅🔆📶📳📴➕➖");
ncplane_putstr_yx(n, 22, 1, "➗❓❔❕💱💲🔱📛🔰✅❌❎➰➿🔟🔠🔡🔢⏯\ufe0f🔣🔤🅰🆎🅱🆑🆒🆓🆔🆕🆖🅾🆗🆘");
ncplane_putstr_yx(n, 23, 1, "🆙🆚🈁🈂🈷🈶🉐🈹🈲🉑🈸🈴🈳🈺🈵🔴🔵🔶🔷🔸🔹🔺🔻💠🔘🔳🔲🏁🚩🎌");
ncplane_putstr_yx(n, 24, 1, "⛧⛤⛢⛦⛥");
return n;
}
@ -3511,10 +3512,10 @@ unicode7emoji2(struct ncplane* title, int y){
struct ncplane*
makegroup(struct ncplane* title, int y, const char* emoji, const char* name){
int cols = mbswidth(emoji);
if(cols < 0){ // take a wild guess on mbswidth() error.
if(cols < 0){ // take a wild guess on mbswidth() error from old libcs, sigh.
cols = strlen(emoji) * 3 / 5; // best by test
}
struct ncplane* n = mojiplane(title, y, 2 + (cols + (planewidth - 3)) / (planewidth - 2), name);
struct ncplane* n = mojiplane(title, y, 3 + cols / (planewidth - 12), name);
if(n == NULL){
return NULL;
}
@ -3705,9 +3706,12 @@ int mojibake_demo(struct notcurses* nc){
break;
}
ncplane_dim_yx(planes[u], &leny, &lenx);
if(y == 1){
if(y == 2){
if(leny > 1){
if(ncplane_resize(planes[u], 1, 0, leny - 1, lenx, -1, 0, leny - 1, lenx)){
if(ncplane_resize(planes[u], 1, 0, leny - 1, lenx, 0, 0, leny - 1, lenx)){
goto err;
}
if(ncplane_move_yx(planes[u], y, x)){
goto err;
}
}else{

@ -137,6 +137,7 @@ draw_background(struct notcurses* nc){
ncvisual_destroy(ncv);
return -1;
}
ncplane_greyscale(n);
}
return 0;
}

@ -381,12 +381,14 @@ int ncvisual_init(int loglevel);
static inline int
fbcellidx(int row, int rowlen, int col){
//fprintf(stderr, "row: %d rowlen: %d col: %d\n", row, rowlen, col);
return row * rowlen + col;
}
// take a logical 'y' and convert it to the virtual 'y'. see HACKING.md.
static inline int
logical_to_virtual(const ncplane* n, int y){
//fprintf(stderr, "y: %d n->logrow: %d n->leny: %d\n", y, n->logrow, n->leny);
return (y + n->logrow) % n->leny;
}

@ -1,26 +0,0 @@
#include <unistd.h>
#include "notcurses/notcurses.h"
int main(void){
struct notcurses_options nopts = {
.flags = NCOPTION_NO_ALTERNATE_SCREEN,
};
struct notcurses* nc = notcurses_init(&nopts, NULL);
if(nc == NULL){
return EXIT_FAILURE;
}
if(ncplane_putstr_aligned(notcurses_stdplane(nc), 0, NCALIGN_CENTER,
"Heute Die Welt, Morgens Das Sonnensystem!") <= 0){
notcurses_stop(nc);
return EXIT_FAILURE;
}
if(ncplane_putstr_aligned(notcurses_stdplane(nc), 2, NCALIGN_CENTER,
"Heute Die Welt, Morgens Das Sonnensystem!") <= 0){
notcurses_stop(nc);
return EXIT_FAILURE;
}
notcurses_render(nc);
sleep(5);
notcurses_stop(nc);
return EXIT_SUCCESS;
}
Loading…
Cancel
Save