[prev in list] [next in list] [prev in thread] [next in thread]
List: kwrite-devel
Subject: [PATCH] Triple click selects line
From: Nadeem Hasan <nhasan () nadmm ! com>
Date: 2002-03-06 23:41:46
[Download RAW message or body]
Hi,
Here is a patch that implements tripleclick for kateview.
Cheers,
--=20
Nadeem Hasan
nhasan@nadmm.com
http://www.nadmm.com/
["kate3.diff" (text/x-diff)]
Index: katedocument.cpp
===================================================================
RCS file: /home/kde/kdelibs/kate/part/katedocument.cpp,v
retrieving revision 1.163
diff -u -r1.163 katedocument.cpp
--- katedocument.cpp 2002/03/06 23:10:58 1.163
+++ katedocument.cpp 2002/03/06 23:34:48
@@ -2988,6 +2988,12 @@
setSelection (cursor.line, start, cursor.line, end);
}
+void KateDocument::selectLine(KateTextCursor &cursor, int flags) {
+ TextLine::Ptr textLine = getTextLine(cursor.line);
+ if (!(flags & KateDocument::cfKeepSelection)) clearSelection ();
+ setSelection (cursor.line, 0, cursor.line+1, 0);
+}
+
void KateDocument::selectLength(KateTextCursor &cursor, int length, int flags) {
int start, end;
Index: katedocument.h
===================================================================
RCS file: /home/kde/kdelibs/kate/part/katedocument.h,v
retrieving revision 1.79
diff -u -r1.79 katedocument.h
--- katedocument.h 2002/03/05 23:13:26 1.79
+++ katedocument.h 2002/03/06 23:34:49
@@ -542,6 +542,7 @@
void selectTo(VConfig &c, KateTextCursor &cursor, int cXPos);
void selectWord(KateTextCursor &cursor, int flags);
+ void selectLine(KateTextCursor &cursor, int flags);
void selectLength(KateTextCursor &cursor, int length, int flags);
void indent(VConfig &c) {doIndent(c, 1);}
Index: kateview.cpp
===================================================================
RCS file: /home/kde/kdelibs/kate/part/kateview.cpp,v
retrieving revision 1.115
diff -u -r1.115 kateview.cpp
--- kateview.cpp 2002/03/06 23:29:24 1.115
+++ kateview.cpp 2002/03/06 23:34:50
@@ -137,6 +137,7 @@
cXPos = 0;
cOldXPos = 0;
+ possibleTripleClick = false;
exposeCursor = false;
updateState = 0;
newXPos = -1;
@@ -1043,6 +1044,16 @@
void KateViewInternal::mousePressEvent(QMouseEvent *e) {
if (e->button() == LeftButton) {
+ if (possibleTripleClick) {
+ possibleTripleClick = false;
+ VConfig c;
+ getVConfig(c);
+ myDoc->selectLine(c.cursor, c.flags);
+ cursor.col = 0;
+ cursor.line = cursor.line;
+ updateCursor( cursor, true );
+ return;
+ }
if (isTargetSelected(e->x(), e->y())) {
// we have a mousedown on selected text
@@ -1091,9 +1102,17 @@
updateCursor( cursor, true );
}
//myDoc->updateViews(); allready called by document->setSelection()
+ possibleTripleClick=true;
+ QTimer::singleShot( QApplication::doubleClickInterval(),this,
+ SLOT(tripleClickTimeout()) );
}
}
+void KateViewInternal::tripleClickTimeout()
+{
+ possibleTripleClick=false;
+}
+
void KateViewInternal::mouseReleaseEvent(QMouseEvent *e) {
if (e->button() == LeftButton) {
Index: kateview.h
===================================================================
RCS file: /home/kde/kdelibs/kate/part/kateview.h,v
retrieving revision 1.57
diff -u -r1.57 kateview.h
--- kateview.h 2002/03/05 23:13:26 1.57
+++ kateview.h 2002/03/06 23:34:50
@@ -137,6 +137,7 @@
private slots:
void changeXPos(int);
void changeYPos(int);
+ void tripleClickTimeout();
private:
void getVConfig(VConfig &);
@@ -206,6 +207,7 @@
int endLine;
uint maxLen;
+ bool possibleTripleClick;
bool exposeCursor;
int updateState;
uint numLines;
_______________________________________________
kwrite-devel mailing list
kwrite-devel@mail.kde.org
http://mail.kde.org/mailman/listinfo/kwrite-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic