/*
 * Copy_Lines_Containing.bsh - Copies lines from current buffer that
 * contain a user-supplied string to the clipboard.
 * 
 * Copyright (C) 2004 Ollie Rutherfurd <oliver@jedit.org>
 *
 * $Id: Copy_Lines_Containing.bsh 5098 2004-08-03 21:31:48Z orutherfurd $
 */

copyLinesContaining(){
	String text = Macros.input(view,"Copy lines containing:");
	if(text == null || "".equals(text))
		return;
	int count = 0;
	StringBuffer buff = new StringBuffer();
	for(int i = 0; i < buffer.getLineCount(); i++){
		String line = buffer.getLineText(i);
		if(line.indexOf(text) > -1){
			buff.append(line).append('\n');
			count++;
		}
	}
	Registers.setRegister('$',buff.toString());
	HistoryModel.getModel("clipboard").addItem(buff.toString());
	view.getStatus().setMessageAndClear("" + count + " lines copied");
}

copyLinesContaining();
