modified move_cursor, make sure works well on linux