#include <ncurses.h>

#include "../../../src/contents.hh"
#include "../../../src/key_aliases.hh"
#include "../../vick-move/src/move.hh"

void enter_insert_mode(contents& contents, boost::optional<int>) {
    char ch;
    contents.is_inserting = true;
    while((ch = getch()) != _escape) {
        contents.cont[contents.y].insert(contents.x, 1, ch);
        mvf(contents);
        if(get_contents().refresh) {
            print_contents(get_contents());
        }
    }
    contents.is_inserting = false;
}

void enter_replace_mode(contents& contents, boost::optional<int>) {
    char ch;
    contents.is_inserting = true;
    while((ch = getch()) != _escape) {
        if(contents.x >= contents.cont[contents.y].size()) {
            contents.cont[contents.y].push_back(ch);
        } else {
            contents.cont[contents.y][contents.x] = ch;
        }
        if(get_contents().refresh) {
            print_contents(get_contents());
        }
    }
    contents.is_inserting = false;
}

#include <ncurses.h>

#include "../../../src/contents.hh"
#include "../../../src/key_aliases.hh"
#include "../../vick-move/src/move.hh"

void enter_insert_mode(contents& contents, boost::optional<int>) {
    char ch;
    while((ch = getch()) != _escape) {
        contents.cont[contents.y].insert(contents.x, 1, ch);
        mvf(contents);
        if(get_contents().refresh) {
            print_contents(get_contents());
        }
    }
}

void enter_replace_mode(contents& contents, boost::optional<int>) {
    char ch;
    while((ch = getch()) != _escape) {
        if(contents.x >= contents.cont[contents.y].size()) {
            contents.cont[contents.y].push_back(ch);
        } else {
            contents.cont[contents.y][contents.x] = ch;
        }
        if(get_contents().refresh) {
            print_contents(get_contents());
        }
    }
}

--- 
+++ 
@@ -6,6 +6,7 @@
 
 void enter_insert_mode(contents& contents, boost::optional<int>) {
     char ch;
+    contents.is_inserting = true;
     while((ch = getch()) != _escape) {
         contents.cont[contents.y].insert(contents.x, 1, ch);
         mvf(contents);
@@ -13,10 +14,12 @@
             print_contents(get_contents());
         }
     }
+    contents.is_inserting = false;
 }
 
 void enter_replace_mode(contents& contents, boost::optional<int>) {
     char ch;
+    contents.is_inserting = true;
     while((ch = getch()) != _escape) {
         if(contents.x >= contents.cont[contents.y].size()) {
             contents.cont[contents.y].push_back(ch);
@@ -27,4 +30,5 @@
             print_contents(get_contents());
         }
     }
+    contents.is_inserting = false;
 }
Edit ``contents.is_inserting`` in insert modes
