mathtext PoC: loop properly

pull/1190/head
nick black 4 years ago
parent 5fc0577529
commit 1239ac7a29
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -104,8 +104,8 @@ ignored.
The **label** is printed in the upper left, immediately to the right of the
topmost axis tick (if **NCPLOT_OPTION_LABELTICKSD** was used). The most
recent sample is printed diagonally opposite from the label (if
**NCPLOT_OPTION_PRINTSAMPLE** was used).
recent sample is printed opposite from the label along the independent axis
(if **NCPLOT_OPTION_PRINTSAMPLE** was used).
# NOTES

@ -1,4 +1,3 @@
#define NCPP_EXCEPTIONS_PLEASE
#include <cstdlib>
#include <clocale>
#include <memory>
@ -64,14 +63,23 @@ auto main() -> int {
"ᐊᓕᒍᖅᓂᕆᔭᕌᖓᒃᑯᓱᕋᙱᑦᑐᓐᓇᖅᑐ"
;
std::unique_ptr<Plane> nstd(nc.get_stdplane());
int y, dimy, dimx;
int y = 0, dimy, dimx, x = 0;
nc.get_term_dim(&dimy, &dimx);
nstd->set_scrolling(true);
const char* cptr = c;
do{
if(nstd->putstr(c) <= 0){
return EXIT_FAILURE;
nstd->cursor_move(y, x);
int xmove = nstd->putstr(cptr);
nstd->get_cursor_yx(&y, &x);
xmove = xmove < 0 ? -xmove : xmove;
cptr += xmove;
fprintf(stderr, "XM: %d diff: %ju %d/%d\n", xmove, (uintmax_t)(cptr - c), y, x);
if(cptr - c >= (ptrdiff_t)strlen(c)){
cptr = c;
}
if(x >= dimx - 1){
++y;
x = 0;
}
nstd->get_cursor_yx(&y, nullptr);
}while(y < dimy - 1);
const int HEIGHT = 9;
const int WIDTH = dimx;

@ -12,6 +12,8 @@ int main(int argc, char **argv){
if(argc > 1){
while(*++argv){
const char* arg = *argv;
int totalcols = 0;
int i = 0;
while(*arg){
mbstate_t mbs = {};
wchar_t w;
@ -21,9 +23,16 @@ int main(int argc, char **argv){
return EXIT_FAILURE;
}
int width = wcwidth(w);
printf("w(0x%05lx): %d %lc\n", (long)w, width, w);
printf("w(0x%05lx): %d %lc\t", (long)w, width, w);
if(i++ % 4 == 3){
printf("\n");
}
if(width > 0){
totalcols += width;
}
arg += conv;
}
printf("\n Total width: %d\n\n", totalcols);
}
return EXIT_SUCCESS;
}

Loading…
Cancel
Save