public int markAll(String toMark, boolean matchCase, boolean wholeWord,
					boolean regex) {
		Highlighter h = getHighlighter();
		int numMarked = 0;
		if (toMark!=null && !toMark.equals(markedWord) && h!=null) {
			if (markAllHighlights!=null)
				clearMarkAllHighlights();
			else
				markAllHighlights = new ArrayList(10);
			int caretPos = getCaretPosition();
			markedWord = toMark;
			setCaretPosition(0);
			SearchContext context = new SearchContext();
			context.setSearchFor(toMark);
			context.setMatchCase(matchCase);
			context.setRegularExpression(regex);
			context.setSearchForward(true);
			context.setWholeWord(wholeWord);
			boolean found = SearchEngine.find(this, context);
			while (found) {
				int start = getSelectionStart();
				int end = getSelectionEnd();
				try {
					markAllHighlights.add(h.addHighlight(start, end,
										markAllHighlightPainter));
				} catch (BadLocationException ble) {
					ble.printStackTrace();
				}
				numMarked++;
				found = SearchEngine.find(this, context);
			}
			setCaretPosition(caretPos);
			repaint();
		}
		return numMarked;
	}