Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the new line character part of the same line as the previous character

Why am I asking?

I am given the severe task of re-implementing the text box GUI widget AND the type writer, so this is the origin of this question.


Current approach of mine

Currently in my project, the new line character \n holds position coordinates of an eventual first character on the next line (column1, line+1). However, I am afraid that this isn't the standard understanding of the newline position.


Question

Is the new line character \n part of the same line as the previous character, is it part of the following line (as it is in my current approach) or neither of these ?


Does it make a difference?

I am experiencing complications when erasing the new line with the backspace, because I have to implement a specific condition for this event, but I am trying to avoid this (or it could be avoided by changing the way I treat the new line character), because from all these conditions it looks like I am trying to invent AI or something.

like image 871
Imobilis Avatar asked Feb 10 '23 05:02

Imobilis


1 Answers

In general, the newline \n is the part of the current line, and when interpreted, emits a visual representation of the end of a line and moves the next character (onwards) to be printed on the next line.

like image 168
Sourav Ghosh Avatar answered Feb 11 '23 22:02

Sourav Ghosh