Four fixes for the console (non-curses unless stated otherwise)

# 1. Word wrap
Word wrap had weird behavior. For example gggggggggggggggggg could be formatted as
gggggggg
ggg
ggggggg
Also, color strings were counted in the word length.
# 2. Bugs in reformatting after the console size changes
One bug is that empty lines cause lines at the top to be removed after a resize. For example, type 'echo' several times, change r_customwidth, and vid_restart. Then the first few lines in the console will be lost.
Additionally, the very first line may be lost due to some indices being off by 1.
# 3. Glitchy drawing of the text that is currently being entered
If the console width is small enough that less than 16 characters can be displayed on the edit line,  things happen. Type in a few characters and then it starts to flicker and display garbage characters. The scroll position gets a negative index and reads text from a random memory location.
Also, calculation of the number of characters that can be displayed in the input field was off by 1.
# 4.Windows curses console has incorrect colors
A one-liner to correctly match up color indices with the array that specifies them.