title: c - custom input, text overwrites when writing at the middle of a word in the command line
body: <p>I'm writing a custom shell in C. I'm currently trying to get the user input.</p>
  
  <p>I've put the terminal in raw mode:</p>
  
  <pre><code>term.c_iflag &amp;= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON);
  term.c_oflag &amp;= ~OPOST;
  term.c_lflag &amp;= ~(ECHO | ECHONL | ICANON | IEXTEN);
  term.c_cflag &amp;= ~(CSIZE | PARENB);
  term.c_cflag |= CS8;
  term.c_cc[VMIN] = 1;
  term.c_cc[VTIME] = 0;
  </code></pre>
  
  <p>so that I can process arrow keys and other special keys.</p>
  
  <p>The problem I have is that when I try to write something in the middle of a word, the text gets overwritten.</p>
  
  <p>I get this:</p>
  
  <p><a href="https://i.stack.imgur.com/rqG2B.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rqG2B.jpg" alt="enter image description here"></a></p>
  
  <p>But I need this:</p>
  
  <p><a href="https://i.stack.imgur.com/haDDV.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/haDDV.jpg" alt="enter image description here"></a></p>
  
  <p>Note: I initially have the string "abc", and with the cursor at 'b', I press 'z'. In my case, 'z' overwrites 'b', but I need it to be inserted between 'a' and 'b', and move "bc" to the right with one column.</p>
  
  <p>Is there a flag in termios that I'm missing or I have to process everything the hard way?</p>