You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
719 lines
17 KiB
719 lines
17 KiB
15 years ago
|
/* This file is part of the KDE libraries
|
||
|
|
||
|
Copyright (C) 1997 Bernd Johannes Wuebben <wuebben@math.cornell.edu>
|
||
|
Copyright (C) 2000 Waldo Bastian <bastian@kde.org>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License as published by the Free Software Foundation; either
|
||
|
version 2 of the License, or (at your option) any later version.
|
||
|
|
||
|
This library 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
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
15 years ago
|
#include <tqdragobject.h>
|
||
|
#include <tqpopupmenu.h>
|
||
|
#include <tqtextstream.h>
|
||
|
#include <tqtimer.h>
|
||
15 years ago
|
|
||
|
#include <kapplication.h>
|
||
|
#include <kcursor.h>
|
||
|
#include <kdebug.h>
|
||
|
#include <kcmenumngr.h>
|
||
|
#include <kfontdialog.h>
|
||
|
#include <klocale.h>
|
||
|
#include <kmessagebox.h>
|
||
|
#include <kstdaccel.h>
|
||
|
#include <kurldrag.h>
|
||
|
|
||
|
#include "keditcl.h"
|
||
|
#include "keditcl.moc"
|
||
|
|
||
|
class KEdit::KEditPrivate
|
||
|
{
|
||
|
public:
|
||
|
bool overwriteEnabled:1;
|
||
|
bool posDirty:1;
|
||
|
bool autoUpdate:1;
|
||
|
};
|
||
|
|
||
|
|
||
15 years ago
|
KEdit::KEdit(TQWidget *_parent, const char *name)
|
||
|
: TQMultiLineEdit(_parent, name)
|
||
15 years ago
|
{
|
||
|
d = new KEditPrivate;
|
||
|
d->overwriteEnabled = false;
|
||
|
d->posDirty = true;
|
||
|
d->autoUpdate = true;
|
||
|
|
||
|
parent = _parent;
|
||
|
|
||
|
// set some defaults
|
||
|
|
||
|
line_pos = col_pos = 0;
|
||
|
|
||
|
srchdialog = NULL;
|
||
14 years ago
|
replace_dialog= NULL;
|
||
15 years ago
|
gotodialog = NULL;
|
||
|
|
||
|
setAcceptDrops(true);
|
||
|
KCursor::setAutoHideCursor( this, true );
|
||
|
|
||
15 years ago
|
connect(this, TQT_SIGNAL(cursorPositionChanged(int,int)),
|
||
|
this, TQT_SLOT(slotCursorPositionChanged()));
|
||
15 years ago
|
}
|
||
|
|
||
|
|
||
|
KEdit::~KEdit()
|
||
|
{
|
||
|
delete d;
|
||
|
}
|
||
|
|
||
|
void
|
||
|
KEdit::setAutoUpdate(bool b)
|
||
|
{
|
||
|
d->autoUpdate = b;
|
||
|
}
|
||
|
|
||
|
void
|
||
15 years ago
|
KEdit::insertText(TQTextStream *stream)
|
||
15 years ago
|
{
|
||
|
// setAutoUpdate(false);
|
||
|
int line, col;
|
||
|
getCursorPosition(&line, &col);
|
||
|
int saveline = line;
|
||
|
int savecol = col;
|
||
15 years ago
|
TQString textLine;
|
||
15 years ago
|
|
||
|
// MS: Patch by Martin Schenk <martin@schenk.com>
|
||
15 years ago
|
// MS: disable UNDO, or TQMultiLineEdit remembers every textLine !!!
|
||
15 years ago
|
// memory usage is:
|
||
|
// textLine: 2*size rounded up to nearest power of 2 (520Kb -> 1024Kb)
|
||
|
// widget: about (2*size + 60bytes*lines)
|
||
|
// -> without disabling undo, it often needs almost 8*size
|
||
|
int oldUndoDepth = undoDepth();
|
||
|
setUndoDepth( 0 ); // ### -1?
|
||
|
|
||
|
// MS: read everything at once if file <= 1MB,
|
||
|
// else read in 5000-line chunks to keep memory usage acceptable.
|
||
14 years ago
|
TQIODevice *dev=stream->tqdevice();
|
||
15 years ago
|
if (dev && dev->size()>(1024*1024)) {
|
||
|
while(1) {
|
||
|
int i;
|
||
|
textLine="";
|
||
|
for (i=0; i<5000; i++) {
|
||
15 years ago
|
TQString line=stream->readLine();
|
||
15 years ago
|
if (line.isNull()) break; // EOF
|
||
|
textLine+=line+'\n';
|
||
|
}
|
||
|
insertAt(textLine, line, col);
|
||
|
line+=i; col=0;
|
||
|
if (i!=5000) break;
|
||
|
}
|
||
|
}
|
||
|
else {
|
||
|
textLine = stream->read(); // Read all !
|
||
|
insertAt( textLine, line, col);
|
||
|
}
|
||
|
setUndoDepth( oldUndoDepth );
|
||
|
|
||
|
setCursorPosition(saveline, savecol);
|
||
|
// setAutoUpdate(true);
|
||
|
|
||
14 years ago
|
// tqrepaint();
|
||
15 years ago
|
|
||
|
setModified(true);
|
||
|
setFocus();
|
||
|
|
||
|
// Bernd: Please don't leave debug message like that lying around
|
||
|
// they cause ENORMOUSE performance hits. Once upon a day
|
||
|
// kedit used to be really really fast using memmap etc .....
|
||
|
// oh well ....
|
||
|
|
||
15 years ago
|
// TQString str = text();
|
||
15 years ago
|
// for (int i = 0; i < (int) str.length(); i++)
|
||
14 years ago
|
// printf("KEdit: U+%04X\n", str[i].tqunicode());
|
||
15 years ago
|
|
||
|
}
|
||
|
|
||
|
void
|
||
|
KEdit::cleanWhiteSpace()
|
||
|
{
|
||
|
d->autoUpdate = false;
|
||
|
if (!hasMarkedText())
|
||
|
selectAll();
|
||
15 years ago
|
TQString oldText = markedText();
|
||
|
TQString newText;
|
||
|
TQStringList lines = TQStringList::split('\n', oldText, true);
|
||
15 years ago
|
bool addSpace = false;
|
||
|
bool firstLine = true;
|
||
15 years ago
|
TQChar lastChar = oldText[oldText.length()-1];
|
||
|
TQChar firstChar = oldText[0];
|
||
|
for(TQStringList::Iterator it = lines.begin();
|
||
15 years ago
|
it != lines.end();)
|
||
|
{
|
||
15 years ago
|
TQString line = (*it).simplifyWhiteSpace();
|
||
15 years ago
|
if (line.isEmpty())
|
||
|
{
|
||
|
if (addSpace)
|
||
14 years ago
|
newText += TQString::tqfromLatin1("\n\n");
|
||
15 years ago
|
if (firstLine)
|
||
|
{
|
||
|
if (firstChar.isSpace())
|
||
|
newText += '\n';
|
||
|
firstLine = false;
|
||
|
}
|
||
|
addSpace = false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (addSpace)
|
||
|
newText += ' ';
|
||
|
if (firstLine)
|
||
|
{
|
||
|
if (firstChar.isSpace())
|
||
|
newText += ' ';
|
||
|
firstLine = false;
|
||
|
}
|
||
|
newText += line;
|
||
|
addSpace = true;
|
||
|
}
|
||
|
it = lines.remove(it);
|
||
|
}
|
||
|
if (addSpace)
|
||
|
{
|
||
|
if (lastChar == '\n')
|
||
|
newText += '\n';
|
||
|
else if (lastChar.isSpace())
|
||
|
newText += ' ';
|
||
|
}
|
||
|
|
||
|
if (oldText == newText)
|
||
|
{
|
||
|
deselect();
|
||
|
d->autoUpdate = true;
|
||
14 years ago
|
tqrepaint();
|
||
15 years ago
|
return;
|
||
|
}
|
||
|
if (wordWrap() == NoWrap)
|
||
|
{
|
||
|
// If wordwrap is off, we have to do some line-wrapping ourselves now
|
||
15 years ago
|
// We use another TQMultiLineEdit for this, so that we get nice undo
|
||
15 years ago
|
// behavior.
|
||
15 years ago
|
TQMultiLineEdit *we = new TQMultiLineEdit();
|
||
15 years ago
|
we->setWordWrap(FixedColumnWidth);
|
||
|
we->setWrapColumnOrWidth(78);
|
||
|
we->setText(newText);
|
||
15 years ago
|
newText = TQString::null;
|
||
15 years ago
|
for(int i = 0; i < we->numLines(); i++)
|
||
|
{
|
||
15 years ago
|
TQString line = we->textLine(i);
|
||
15 years ago
|
if (line.right(1) != "\n")
|
||
|
line += '\n';
|
||
|
newText += line;
|
||
|
}
|
||
|
delete we;
|
||
|
}
|
||
|
|
||
|
insert(newText);
|
||
|
d->autoUpdate = true;
|
||
14 years ago
|
tqrepaint();
|
||
15 years ago
|
|
||
|
setModified(true);
|
||
|
setFocus();
|
||
|
}
|
||
|
|
||
|
|
||
|
void
|
||
15 years ago
|
KEdit::saveText(TQTextStream *stream)
|
||
15 years ago
|
{
|
||
|
saveText(stream, false);
|
||
|
}
|
||
|
|
||
|
void
|
||
15 years ago
|
KEdit::saveText(TQTextStream *stream, bool softWrap)
|
||
15 years ago
|
{
|
||
|
int line_count = numLines()-1;
|
||
|
if (line_count < 0)
|
||
|
return;
|
||
|
|
||
|
if (softWrap || (wordWrap() == NoWrap))
|
||
|
{
|
||
|
for(int i = 0; i < line_count; i++)
|
||
|
{
|
||
|
(*stream) << textLine(i) << '\n';
|
||
|
}
|
||
|
(*stream) << textLine(line_count);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
for(int i = 0; i <= line_count; i++)
|
||
|
{
|
||
|
int lines_in_parag = linesOfParagraph(i);
|
||
|
if (lines_in_parag == 1)
|
||
|
{
|
||
|
(*stream) << textLine(i);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
15 years ago
|
TQString parag_text = textLine(i);
|
||
15 years ago
|
int pos = 0;
|
||
|
int first_pos = 0;
|
||
|
int current_line = 0;
|
||
|
while(true) {
|
||
|
while(lineOfChar(i, pos) == current_line) pos++;
|
||
|
(*stream) << parag_text.mid(first_pos, pos - first_pos - 1) << '\n';
|
||
|
current_line++;
|
||
|
first_pos = pos;
|
||
|
if (current_line+1 == lines_in_parag)
|
||
|
{
|
||
|
// Last line
|
||
|
(*stream) << parag_text.mid(pos);
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if (i < line_count)
|
||
|
(*stream) << '\n';
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
int KEdit::currentLine(){
|
||
|
|
||
|
computePosition();
|
||
|
return line_pos;
|
||
|
|
||
|
}
|
||
|
|
||
|
int KEdit::currentColumn(){
|
||
|
|
||
|
computePosition();
|
||
|
return col_pos;
|
||
|
}
|
||
|
|
||
|
void KEdit::slotCursorPositionChanged()
|
||
|
{
|
||
|
d->posDirty = true;
|
||
|
emit CursorPositionChanged();
|
||
|
}
|
||
|
|
||
|
void KEdit::computePosition()
|
||
|
{
|
||
|
if (!d->posDirty) return;
|
||
|
d->posDirty = false;
|
||
|
|
||
|
int line, col;
|
||
|
|
||
|
getCursorPosition(&line,&col);
|
||
|
|
||
|
// line is expressed in paragraphs, we now need to convert to lines
|
||
|
line_pos = 0;
|
||
|
if (wordWrap() == NoWrap)
|
||
|
{
|
||
|
line_pos = line;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
for(int i = 0; i < line; i++)
|
||
|
line_pos += linesOfParagraph(i);
|
||
|
}
|
||
|
|
||
|
int line_offset = lineOfChar(line, col);
|
||
|
line_pos += line_offset;
|
||
|
|
||
|
// We now calculate where the current line starts in the paragraph.
|
||
15 years ago
|
TQString linetext = textLine(line);
|
||
15 years ago
|
int start_of_line = 0;
|
||
|
if (line_offset > 0)
|
||
|
{
|
||
|
start_of_line = col;
|
||
|
while(lineOfChar(line, --start_of_line) == line_offset);
|
||
|
start_of_line++;
|
||
|
}
|
||
|
|
||
|
|
||
|
// O.K here is the deal: The function getCursorPositoin returns the character
|
||
|
// position of the cursor, not the screenposition. I.e,. assume the line
|
||
|
// consists of ab\tc then the character c will be on the screen on position 8
|
||
|
// whereas getCursorPosition will return 3 if the cursors is on the character c.
|
||
|
// Therefore we need to compute the screen position from the character position.
|
||
|
// That's what all the following trouble is all about:
|
||
|
|
||
|
int coltemp = col-start_of_line;
|
||
|
int pos = 0;
|
||
14 years ago
|
int find = 0;
|
||
15 years ago
|
int mem = 0;
|
||
|
bool found_one = false;
|
||
|
|
||
|
// if you understand the following algorithm you are worthy to look at the
|
||
|
// kedit+ sources -- if not, go away ;-)
|
||
|
|
||
|
|
||
14 years ago
|
while(find >=0 && find <= coltemp- 1 ){
|
||
13 years ago
|
find = linetext.find('\t', find+start_of_line, true )-start_of_line;
|
||
14 years ago
|
if( find >=0 && find <= coltemp - 1 ){
|
||
15 years ago
|
found_one = true;
|
||
14 years ago
|
pos = pos + find - mem;
|
||
15 years ago
|
pos = pos + 8 - pos % 8;
|
||
14 years ago
|
mem = find;
|
||
|
find ++;
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
|
pos = pos + coltemp - mem; // add the number of characters behind the
|
||
|
// last tab on the line.
|
||
|
|
||
|
if (found_one){
|
||
|
pos = pos - 1;
|
||
|
}
|
||
|
|
||
|
col_pos = pos;
|
||
|
}
|
||
|
|
||
|
|
||
15 years ago
|
void KEdit::keyPressEvent ( TQKeyEvent *e)
|
||
15 years ago
|
{
|
||
|
// ignore Ctrl-Return so that KDialogBase can catch them
|
||
|
if ( e->key() == Key_Return && e->state() == ControlButton ) {
|
||
|
e->ignore();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
KKey key(e);
|
||
|
int keyQt = key.keyCodeQt();
|
||
|
|
||
|
if ( keyQt == CTRL+Key_K ){
|
||
|
|
||
|
int line = 0;
|
||
|
int col = 0;
|
||
15 years ago
|
TQString killstring;
|
||
15 years ago
|
|
||
|
if(!killing){
|
||
|
killbufferstring = "";
|
||
|
killtrue = false;
|
||
|
lastwasanewline = false;
|
||
|
}
|
||
|
|
||
|
if(!atEnd()){
|
||
|
|
||
|
getCursorPosition(&line,&col);
|
||
|
killstring = textLine(line);
|
||
|
killstring = killstring.mid(col,killstring.length());
|
||
|
|
||
|
|
||
|
if(!killbufferstring.isEmpty() && !killtrue && !lastwasanewline){
|
||
|
killbufferstring += '\n';
|
||
|
}
|
||
|
|
||
|
if( (killstring.length() == 0) && !killtrue){
|
||
|
killbufferstring += '\n';
|
||
|
lastwasanewline = true;
|
||
|
}
|
||
|
|
||
|
if(killstring.length() > 0){
|
||
|
|
||
|
killbufferstring += killstring;
|
||
|
lastwasanewline = false;
|
||
|
killtrue = true;
|
||
|
|
||
|
}else{
|
||
|
|
||
|
lastwasanewline = false;
|
||
|
killtrue = !killtrue;
|
||
|
|
||
|
}
|
||
|
|
||
|
}else{
|
||
|
|
||
|
if(killbufferstring.isEmpty() && !killtrue && !lastwasanewline){
|
||
|
killtrue = true;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
killing = true;
|
||
|
|
||
15 years ago
|
TQMultiLineEdit::keyPressEvent(e);
|
||
15 years ago
|
setModified(true);
|
||
|
return;
|
||
|
}
|
||
|
else if ( keyQt == CTRL+Key_Y ){
|
||
|
|
||
|
int line = 0;
|
||
|
int col = 0;
|
||
|
|
||
|
getCursorPosition(&line,&col);
|
||
|
|
||
15 years ago
|
TQString tmpstring = killbufferstring;
|
||
15 years ago
|
if(!killtrue)
|
||
|
tmpstring += '\n';
|
||
|
|
||
|
insertAt(tmpstring,line,col);
|
||
|
|
||
|
killing = false;
|
||
|
setModified(true);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
killing = false;
|
||
|
|
||
14 years ago
|
if ( KStdAccel::copy().contains( key ) )
|
||
15 years ago
|
copy();
|
||
|
else if ( isReadOnly() )
|
||
15 years ago
|
TQMultiLineEdit::keyPressEvent( e );
|
||
|
// If this is an unmodified printable key, send it directly to TQMultiLineEdit.
|
||
14 years ago
|
else if ( !(key.keyCodeQt() & (CTRL | ALT)) && !e->text().isEmpty() && TQString(e->text()).tqunicode()->isPrint() )
|
||
15 years ago
|
TQMultiLineEdit::keyPressEvent( e );
|
||
14 years ago
|
else if ( KStdAccel::paste().contains( key ) ) {
|
||
15 years ago
|
paste();
|
||
|
setModified(true);
|
||
|
slotCursorPositionChanged();
|
||
|
}
|
||
14 years ago
|
else if ( KStdAccel::cut().contains( key ) ) {
|
||
15 years ago
|
cut();
|
||
|
setModified(true);
|
||
|
slotCursorPositionChanged();
|
||
|
}
|
||
14 years ago
|
else if ( KStdAccel::undo().contains( key ) ) {
|
||
15 years ago
|
undo();
|
||
|
setModified(true);
|
||
|
slotCursorPositionChanged();
|
||
|
}
|
||
14 years ago
|
else if ( KStdAccel::redo().contains( key ) ) {
|
||
15 years ago
|
redo();
|
||
|
setModified(true);
|
||
|
slotCursorPositionChanged();
|
||
|
}
|
||
14 years ago
|
else if ( KStdAccel::deleteWordBack().contains( key ) ) {
|
||
15 years ago
|
moveCursor(MoveWordBackward, true);
|
||
|
if (hasSelectedText())
|
||
|
del();
|
||
|
setModified(true);
|
||
|
slotCursorPositionChanged();
|
||
|
}
|
||
14 years ago
|
else if ( KStdAccel::deleteWordForward().contains( key ) ) {
|
||
15 years ago
|
moveCursor(MoveWordForward, true);
|
||
|
if (hasSelectedText())
|
||
|
del();
|
||
|
setModified(true);
|
||
|
slotCursorPositionChanged();
|
||
|
}
|
||
14 years ago
|
else if ( KStdAccel::backwardWord().contains( key ) ) {
|
||
15 years ago
|
CursorAction action = MoveWordBackward;
|
||
|
int para, index;
|
||
|
getCursorPosition( ¶, & index );
|
||
|
if (text(para).isRightToLeft())
|
||
|
action = MoveWordForward;
|
||
|
moveCursor(action, false );
|
||
|
slotCursorPositionChanged();
|
||
|
}
|
||
14 years ago
|
else if ( KStdAccel::forwardWord().contains( key ) ) {
|
||
15 years ago
|
CursorAction action = MoveWordForward;
|
||
|
int para, index;
|
||
|
getCursorPosition( ¶, & index );
|
||
|
if (text(para).isRightToLeft())
|
||
|
action = MoveWordBackward;
|
||
|
moveCursor( action, false );
|
||
|
slotCursorPositionChanged();
|
||
|
}
|
||
14 years ago
|
else if ( KStdAccel::next().contains( key ) ) {
|
||
15 years ago
|
moveCursor( MovePgDown, false );
|
||
|
slotCursorPositionChanged();
|
||
|
}
|
||
14 years ago
|
else if ( KStdAccel::prior().contains( key ) ) {
|
||
15 years ago
|
moveCursor( MovePgUp, false );
|
||
|
slotCursorPositionChanged();
|
||
|
}
|
||
14 years ago
|
else if ( KStdAccel::home().contains( key ) ) {
|
||
15 years ago
|
moveCursor( MoveHome, false );
|
||
|
slotCursorPositionChanged();
|
||
|
}
|
||
14 years ago
|
else if ( KStdAccel::end().contains( key ) ) {
|
||
15 years ago
|
moveCursor( MoveEnd, false );
|
||
|
slotCursorPositionChanged();
|
||
|
}
|
||
14 years ago
|
else if ( KStdAccel::beginningOfLine().contains( key ) ) {
|
||
15 years ago
|
moveCursor( MoveLineStart, false);
|
||
|
slotCursorPositionChanged();
|
||
|
}
|
||
14 years ago
|
else if ( KStdAccel::endOfLine().contains( key ) ) {
|
||
15 years ago
|
moveCursor( MoveLineEnd, false);
|
||
|
slotCursorPositionChanged();
|
||
|
}
|
||
|
else if ( key == Key_Insert ) {
|
||
|
if (d->overwriteEnabled)
|
||
|
{
|
||
|
this->setOverwriteMode(!this->isOverwriteMode());
|
||
|
emit toggle_overwrite_signal();
|
||
|
}
|
||
|
}
|
||
|
else
|
||
15 years ago
|
TQMultiLineEdit::keyPressEvent(e);
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void KEdit::installRBPopup(TQPopupMenu *p) {
|
||
15 years ago
|
KContextMenuManager::insert( this, p );
|
||
|
}
|
||
|
|
||
|
void KEdit::selectFont(){
|
||
|
|
||
15 years ago
|
TQFont font = this->font();
|
||
15 years ago
|
KFontDialog::getFont(font);
|
||
|
this->setFont(font);
|
||
|
|
||
|
}
|
||
|
|
||
|
void KEdit::doGotoLine() {
|
||
|
|
||
|
if( !gotodialog )
|
||
|
gotodialog = new KEdGotoLine( parent, "gotodialog" );
|
||
|
|
||
|
this->clearFocus();
|
||
|
|
||
|
gotodialog->exec();
|
||
|
// this seems to be not necessary
|
||
|
// gotodialog->setFocus();
|
||
|
if( gotodialog->result() != KEdGotoLine::Accepted)
|
||
|
return;
|
||
|
int target_line = gotodialog->getLineNumber()-1;
|
||
|
if (wordWrap() == NoWrap)
|
||
|
{
|
||
|
setCursorPosition( target_line, 0 );
|
||
|
setFocus();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
int max_parag = paragraphs();
|
||
|
|
||
|
int line = 0;
|
||
|
int parag = -1;
|
||
|
int lines_in_parag = 0;
|
||
|
while ((++parag < max_parag) && (line + lines_in_parag < target_line))
|
||
|
{
|
||
|
line += lines_in_parag;
|
||
|
lines_in_parag = linesOfParagraph(parag);
|
||
|
}
|
||
|
|
||
|
int col = 0;
|
||
|
if (parag >= max_parag)
|
||
|
{
|
||
|
target_line = line + lines_in_parag - 1;
|
||
|
parag = max_parag-1;
|
||
|
}
|
||
|
|
||
|
while(1+line+lineOfChar(parag,col) < target_line) col++;
|
||
|
setCursorPosition( parag, col );
|
||
|
setFocus();
|
||
|
}
|
||
|
|
||
|
|
||
15 years ago
|
void KEdit::dragMoveEvent(TQDragMoveEvent* e) {
|
||
15 years ago
|
|
||
|
if(KURLDrag::canDecode(e))
|
||
|
e->accept();
|
||
15 years ago
|
else if(TQTextDrag::canDecode(e))
|
||
|
TQMultiLineEdit::dragMoveEvent(e);
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void KEdit::contentsDragMoveEvent(TQDragMoveEvent* e) {
|
||
15 years ago
|
|
||
|
if(KURLDrag::canDecode(e))
|
||
|
e->accept();
|
||
15 years ago
|
else if(TQTextDrag::canDecode(e))
|
||
|
TQMultiLineEdit::contentsDragMoveEvent(e);
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void KEdit::dragEnterEvent(TQDragEnterEvent* e) {
|
||
15 years ago
|
|
||
|
kdDebug() << "KEdit::dragEnterEvent()" << endl;
|
||
15 years ago
|
e->accept(KURLDrag::canDecode(e) || TQTextDrag::canDecode(e));
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void KEdit::contentsDragEnterEvent(TQDragEnterEvent* e) {
|
||
15 years ago
|
|
||
|
kdDebug() << "KEdit::contentsDragEnterEvent()" << endl;
|
||
15 years ago
|
e->accept(KURLDrag::canDecode(e) || TQTextDrag::canDecode(e));
|
||
15 years ago
|
}
|
||
|
|
||
|
|
||
15 years ago
|
void KEdit::dropEvent(TQDropEvent* e) {
|
||
15 years ago
|
|
||
|
kdDebug() << "KEdit::dropEvent()" << endl;
|
||
|
|
||
|
if(KURLDrag::canDecode(e)) {
|
||
|
emit gotUrlDrop(e);
|
||
|
}
|
||
15 years ago
|
else if(TQTextDrag::canDecode(e))
|
||
|
TQMultiLineEdit::dropEvent(e);
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void KEdit::contentsDropEvent(TQDropEvent* e) {
|
||
15 years ago
|
|
||
|
kdDebug() << "KEdit::contentsDropEvent()" << endl;
|
||
|
|
||
|
if(KURLDrag::canDecode(e)) {
|
||
|
emit gotUrlDrop(e);
|
||
|
}
|
||
15 years ago
|
else if(TQTextDrag::canDecode(e))
|
||
|
TQMultiLineEdit::contentsDropEvent(e);
|
||
15 years ago
|
}
|
||
|
|
||
|
void KEdit::setOverwriteEnabled(bool b)
|
||
|
{
|
||
|
d->overwriteEnabled = b;
|
||
|
}
|
||
|
|
||
15 years ago
|
// TQWidget::create() turns off mouse-Tracking which would break auto-hiding
|
||
15 years ago
|
void KEdit::create( WId id, bool initializeWindow, bool destroyOldWindow )
|
||
|
{
|
||
15 years ago
|
TQMultiLineEdit::create( id, initializeWindow, destroyOldWindow );
|
||
15 years ago
|
KCursor::setAutoHideCursor( this, true );
|
||
|
}
|
||
|
|
||
|
void KEdit::ensureCursorVisible()
|
||
|
{
|
||
|
if (!d->autoUpdate)
|
||
|
return;
|
||
|
|
||
15 years ago
|
TQMultiLineEdit::ensureCursorVisible();
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void KEdit::setCursor( const TQCursor &c )
|
||
15 years ago
|
{
|
||
|
if (!d->autoUpdate)
|
||
|
return;
|
||
|
|
||
15 years ago
|
TQMultiLineEdit::setCursor(c);
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void KEdit::viewportPaintEvent( TQPaintEvent*pe )
|
||
15 years ago
|
{
|
||
|
if (!d->autoUpdate)
|
||
|
return;
|
||
|
|
||
15 years ago
|
TQMultiLineEdit::viewportPaintEvent(pe);
|
||
15 years ago
|
}
|
||
|
|
||
|
|
||
|
void KEdGotoLine::virtual_hook( int id, void* data )
|
||
|
{ KDialogBase::virtual_hook( id, data ); }
|
||
|
|
||
|
void KEdFind::virtual_hook( int id, void* data )
|
||
|
{ KDialogBase::virtual_hook( id, data ); }
|
||
|
|
||
|
void KEdReplace::virtual_hook( int id, void* data )
|
||
|
{ KDialogBase::virtual_hook( id, data ); }
|
||
|
|
||
|
void KEdit::virtual_hook( int, void* )
|
||
|
{ /*BASE::virtual_hook( id, data );*/ }
|
||
|
|