Avoid redrawing (thus loosing the selection and scroll position) of preview window on style change by defining the colors through CSS styles. On style change we just update the CSS color definitions and preview will update itself without redraw.