From 369b511f9c2b84b8a371ab60bead54ae6b6d317d Mon Sep 17 00:00:00 2001
From: Alexander Golubev <fatzer2@gmail.com>
Date: Thu, 9 Apr 2026 00:34:53 +0300
Subject: tdeui/kcharselect: [refactoring] reuse common code from *goto()
 functions

Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
---
 tdeui/kcharselect.cpp | 59 +++++++++++++++------------------------------------
 tdeui/kcharselect.h   |  1 +
 2 files changed, 18 insertions(+), 42 deletions(-)

diff --git a/tdeui/kcharselect.cpp b/tdeui/kcharselect.cpp
index 27a0ad685..09c478594 100644
--- a/tdeui/kcharselect.cpp
+++ b/tdeui/kcharselect.cpp
@@ -347,17 +347,7 @@ void KCharSelectTable::keyPressEvent( TQKeyEvent *e )
 void KCharSelectTable::gotoLeft()
 {
     if ( focusPos.x() > 0 ) {
-	const TQPoint oldPos = focusPos;
-
-	focusPos.setX( focusPos.x() - 1 );
-
-	focusItem = charAt( focusPos.y(), focusPos.x() );
-
-	repaintCell( oldPos.y(), oldPos.x(), true );
-	repaintCell( focusPos.y(), focusPos.x(), true );
-
-	emit focusItemChanged( vChr );
-	emit focusItemChanged();
+        doGoto(-1, 0);
     }
 }
 
@@ -365,17 +355,7 @@ void KCharSelectTable::gotoLeft()
 void KCharSelectTable::gotoRight()
 {
     if ( focusPos.x() < numCols()-1 ) {
-	const TQPoint oldPos = focusPos;
-
-	focusPos.setX( focusPos.x() + 1 );
-
-	focusItem = charAt( focusPos.y(), focusPos.x() );
-
-	repaintCell( oldPos.y(), oldPos.x(), true );
-	repaintCell( focusPos.y(), focusPos.x(), true );
-
-	emit focusItemChanged( vChr );
-	emit focusItemChanged();
+        doGoto(1, 0);
     }
 }
 
@@ -383,17 +363,7 @@ void KCharSelectTable::gotoRight()
 void KCharSelectTable::gotoUp()
 {
     if ( focusPos.y() > 0 ) {
-	const TQPoint oldPos = focusPos;
-
-	focusPos.setY( focusPos.y() - 1 );
-
-	focusItem = charAt( focusPos.y(), focusPos.x() );
-
-	repaintCell( oldPos.y(), oldPos.x(), true );
-	repaintCell( focusPos.y(), focusPos.x(), true );
-
-	emit focusItemChanged( vChr );
-	emit focusItemChanged();
+        doGoto(0, -1);
     }
 }
 
@@ -401,18 +371,22 @@ void KCharSelectTable::gotoUp()
 void KCharSelectTable::gotoDown()
 {
     if ( focusPos.y() < numRows()-1 ) {
-	const TQPoint oldPos = focusPos;
-
-	focusPos.setY( focusPos.y() + 1 );
+        doGoto(0, +1);
+    }
+}
 
-	focusItem = charAt( focusPos.y(), focusPos.x() );
+//==================================================================
+void KCharSelectTable::doGoto(int dx, int dy)
+{
+    TQPoint oldPos = focusPos;
+    focusPos += TQPoint(dx, dy);
+    focusItem = charAt( focusPos.y(), focusPos.x() );
 
-	repaintCell( oldPos.y(), oldPos.x(), true );
-	repaintCell( focusPos.y(), focusPos.x(), true );
+    repaintCell( oldPos.y(), oldPos.x(), true );
+    repaintCell( focusPos.y(), focusPos.x(), true );
 
-	emit focusItemChanged( vChr );
-	emit focusItemChanged();
-    }
+    emit focusItemChanged( vChr );
+    emit focusItemChanged();
 }
 
 //==================================================================
@@ -420,6 +394,7 @@ TQChar KCharSelectTable::charAt(int row, int col) const
 {
     return TQChar( vTableNum * 256 + numCols() * row + col );
 }
+
 /******************************************************************/
 /* Class: KCharSelect						  */
 /******************************************************************/
diff --git a/tdeui/kcharselect.h b/tdeui/kcharselect.h
index ba767a18d..72245bcb5 100644
--- a/tdeui/kcharselect.h
+++ b/tdeui/kcharselect.h
@@ -103,6 +103,7 @@ signals:
 
 private:
     virtual void setFont(const TQFont &f) { TQGridView::setFont(f); }
+    void doGoto(int dx, int dy);
 protected:
     virtual void virtual_hook( int id, void* data );
 private:
-- 
cgit v1.2.3

