Notcurses 3.0.13
a blingful library for TUIs and character graphics
Loading...
Searching...
No Matches
layout.c File Reference
#include "internal.h"
Include dependency graph for layout.c:

Go to the source code of this file.

Functions

int ncplane_puttext (ncplane *n, int y, ncalign_e align, const char *text, size_t *bytes)
 

Function Documentation

◆ ncplane_puttext()

int ncplane_puttext ( ncplane n,
int  y,
ncalign_e  align,
const char *  text,
size_t *  bytes 
)

Definition at line 149 of file layout.c.

149 {
150 if(bytes){
151 *bytes = 0;
152 }
153 int totalcols = 0;
154 // text points to the text we have *not* yet output. at each step, we see
155 // how much space we have available, and begin iterating from text. remember
156 // the most recent linebreaker that we see. when we exhaust our line, print
157 // through the linebreaker, and advance text.
158 // if we're using NCALIGN_LEFT, we'll be printing with x==-1, i.e. wherever
159 // the cursor is. if there's insufficient room to print anything, we need to
160 // try moving to the next line first. FIXME this ought actually apply to all
161 // alignments, which ought be taken relative to n->x. no change for
162 // NCALIGN_RIGHT, but NCALIGN_CENTER needs explicitly handle it...
163 do{
164 if(y != -1){
165 if(ncplane_cursor_move_yx(n, y, -1)){
166 return -1;
167 }
168 }
169 size_t linebytes = 0;
170 int cols = puttext_line(n, align, text, &linebytes);
171 if(cols < 0){
172 return -1;
173 }
174 totalcols += cols;
175 if(bytes){
176 *bytes += linebytes;
177 }
178 text += linebytes;
179//fprintf(stderr, "new cursor: %d/%d consumed: %zu\n", n->y, n->x, linebytes);
180 y = n->y;
181 }while(*text);
182 return totalcols;
183}
int ncplane_cursor_move_yx(ncplane *n, int y, int x)
Definition notcurses.c:720
int y
Definition notcurses.h:1905
vopts n
Definition notcurses.h:3502
Here is the call graph for this function: