I have a ncurses-based text editor in c++ that uses tabs. Is there a way to make the tab columns shift by a certain amount to account for a side-ruler?
I can start my program with different sized tabs by setting TABSIZE
, eg TABSIZE=4
. This is nice, but on top of this I need to adjust where the first/all tab columns are calculated at.
This is a stripped down version to show the issue. The first and second columns of x's are smaller since the ruler takes away the available space at the start of the line, but the second and last columns are fine.
void write(std::string s) { //helper function
printw(s.c_str());
}
int main() {
initscr(); //start and clear
TABSIZE=8; //default tabsize
refresh();
for (int i=1;i<10;i++) {
write(std::to_string(i)+" | x\tx\tx\n");
}
getch();
endwin();
return 0;
}
//output from above
1 | x x x
2 | x x x
3 | x x x
4 | x x x
5 | x x x
6 | x x x
7 | x x x
8 | x x x
9 | x x x
The end result would be having the tab columns start at the ruler length (eg 3) instead of 0 (start of line)