/** * Installs this highlighter into the specified StyledText object. Client can manually call * detach() method, then wants to destroy this object. */ public void attach(StyledText parent) { detach(); text = parent; text.addDisposeListener(ml); text.addLineStyleListener(ml); text.addLineBackgroundListener(ml); text.addPaintListener(ml); text.addVerifyListener(ml); text.addExtendedModifyListener(ml); text.addControlListener(ml); text.addKeyListener(ml); text.addTraverseListener(ml); text.addMouseListener(ml); text.addSelectionListener(ml); text.getContent().addTextChangeListener(ml); ScrollBar sb = text.getVerticalBar(); if (sb != null) sb.addSelectionListener(ml); updateViewport(); new Thread() { public void run() { // setPriority(Thread.NORM_PRIORITY-1); while (true) { try { sleep(300); } catch (InterruptedException e) { } if (baseEditor == null || text == null) break; if (backParserDelay) { backParserDelay = false; try { sleep(1500); } catch (InterruptedException e) { } continue; } ; Display.getDefault() .syncExec( new Runnable() { public void run() { if (baseEditor == null || text == null) return; if (text.isDisposed()) return; // System.out.println(System.currentTimeMillis()); baseEditor.idleJob(80); // redrawFrom(text.getLineAtOffset(text.getCaretOffset())); } }); } ; }; }.start(); }