1/*
2 * Duplicate_Lines_Above.bsh - a BeanShell macro script for the
3 * jEdit text editor - duplicates the cursor line.
4 * Copyright (C) 2001 Francesc Roses
5 * Copyright (c) 2008 encorejane
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with the jEdit program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20 * based on: Duplicate_Line.bsh 3866 2001-11-06 15:04:21Z jgellene
21 *
22 * Checked for jEdit 4.3 API
23 *
24 */
25
26//Localization
27final static String NotEditableMessage = jEdit.getProperty("macro.rs.general.ErrorNotEditableDialog.message", "Buffer is not editable");
28
29// Process
30void duplicateLinesAbove()
31{
32	selections = textArea.getSelectedLines();
33	if(selections.length == 0){
34		selections = new int [] {textArea.getCaretLine()};
35	}
36	start = textArea.getLineStartOffset(selections[0]);
37	stop = textArea.getLineEndOffset(selections[selections.length-1]);
38	if(stop-1 == textArea.getBufferLength()){
39		text = textArea.getText(start,stop-start-1)+'\n';
40	}else{
41		text = textArea.getText(start,stop-start);
42	}
43	buffer.insert(start, text);
44}
45
46duplicateLinesAbove();
47
48/*
49
50Macro index data (in DocBook format)
51
52  <listitem>
53    <para><filename>Duplicate_Line.bsh</filename></para>
54	<abstract><para>
55	  Duplicates the line on which the caret lies immediately
56	  above it.
57	</para></abstract>
58  </listitem>
59
60*/
61
62// end Duplicate_Line.bsh
63