since rightMargin==WIDTH at this point, I think it's clearer to say (cursorX == WIDTH - 1)