/* * Move_Line_Up.bsh - Beanshell macro to move a line up by one line. * * Copyright (C) 2002 Lee Turner (lee@leeturner.org) * Version 1.0 * * :tabSize=4:indentSize=4:noTabs=false: * :folding=explicit:collapseFolds=1: * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Lets first check to see if the buffer is readonly as we can't make // updates to a readonly buffer now can we...... if(buffer.isReadOnly()) { Macros.error(view, "This file is read only."); return; } // move current line one line up boolean onLastLine = ((textArea.getCaretLine()+1) == buffer.getLineCount()); textArea.selectLine(); Registers.copy(textArea,'_'); textArea.selectNone(); textArea.deleteLine(); if(onLastLine) { textArea.goToStartOfLine(false); Registers.paste(textArea,'_',false); textArea.setSelectedText("\n"); textArea.goToPrevLine(false); } else { textArea.goToPrevLine(false); textArea.goToStartOfLine(false); Registers.paste(textArea,'_',false); textArea.setSelectedText("\n"); textArea.goToPrevLine(false); }