package smart_gs.current_text_search;

import smart_gs.swingui.toolbar.GSEditorToolBar;
import sml_editor.swingui.EditorTextPane;

public class CurrentSearchTextWithoutDialog {
	static GSEditorToolBar gsEditorToolBar;
	static int startposition = -1;
	static int lastpoint = -1;

	public static void search(GSEditorToolBar toolbar, String searchStr) {
		gsEditorToolBar = toolbar;
		startposition = -1;
		lastpoint = -1;
		if(gsEditorToolBar != null){
			if(!searchStr.equals("")){
				EditorTextPane editorTextPane = gsEditorToolBar.getEditorTextPane();
				if(editorTextPane != null){
					String searchText = null;
					if(gsEditorToolBar.getMode() == 0 || gsEditorToolBar.getMode() == 1){
						searchText = editorTextPane.getPainText();
					}else if(gsEditorToolBar.getMode() == 2){
						searchText = editorTextPane.getSource();
					}
					if(searchText == null){
						searchText = "";
					}else{
						searchText = searchText.replaceAll("\r", "");
					}
					editorTextPane.findText(searchStr, null, false,0,true);
				}
			}
		}
	}
}
				