@Flederfalter Back in the day I was studying source codes of various open source editors (SciTE, jEdit, etc.). It all depends on your requirements, but perhaps following tips will help you get started:
TextBuffer: I usually start with creating a Buffer that does not care about Unicode, it's just a glorified array of characters with methods like insertText(position, text) / removeText(position, length). For text storage you might want to check Rope (
http://en.wikipedia.org/wiki/Rope_(data_structure)) or a Gap buffer (
http://en.wikipedia.org/wiki/Gap_buffer). I usually have an option to simply replace the buffer storage, though I usually use Gap buffer (mostly because I know it well).
Lines: Then you need to know where the lines start and end and provide functions to access the lines (begin offset, end offset, length, text retrieval, etc.). For that you can use an array that only remembers where the lines end. Update the array inside the insertText/removeText.
Cursor: The cursor (or caret if you want) is simply a position into the buffer. Some editors blend cursor with selection (so the cursor has two positions). Cursor is usually bound to the buffer and provides functions/methods to change the document (Cursor::insertText(char *text, size_t text_length)).
View: You will need means to convert a position (offset) in a document to screen coordinates and vice versa. Plus means to render the text (line-by-line) on the screen. For that you'll need to know the font and the concrete text layout on the screen. Simplest form is to use bitmap/fixed-width fonts with only basic character set (Latin1), so that each character in the buffer maps exactly to one character on the screen, preferably with each character having the same pixel-width.
Input: Simply use platform events/messages to get characters typed, or keys pressed to move the cursor and insert typed text.
Syntax Highlighting: Most "modern" code editors today use TextMate grammars, which is a bunch of regular expressions to match the code and apply colors to it (usually via a theme that works similar to CSS). You don't need that as long as you want only limited amount of languages (preferably only C/C++), few regular expressions or small parsers for strings, comments and numbers should do the trick.
The parsing is usually done line-by-line. When a text on a line text changes, the parser goes character by character on that line and stores the recognized part (either as direct color, or as a general token type) along with their positions and lenghts in an array. That array is later used with rendering to color the code.