[Bug 82662] new feature: (global) cursor position history

andreas braendle abraendle at gmx.de
Fri Jun 4 00:37:21 UTC 2004


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
      
http://bugs.kde.org/show_bug.cgi?id=82662      




------- Additional Comments From abraendle gmx de  2004-06-01 22:21 -------
// CURSHIST.H

#ifndef CURSHIST_H
#define CURSHIST_H


// written by (C) Andreas Brändle <abraendle gmx de>  10.01.04
// published under GPL

// TODO: Implement this useful feature also into other IDEs/editors!!

/*

You need:

* 4 application-global keys: Left, Right, Up, Down
(Light-version 2 keys: Right, Left  -also possible)

* one application-global object of this class

* the editor-views must know about this object and inform it when the cursor position has
  changed, because - a character was entered
                   - cursor keys pressed
  especially NOT when - Page/UpDown pressed
                      - Mouse clicked

  also when a file/view is closed

* catch the events for the 4 keys globally and change to the appropriate view+cursorposition

thats all...

*/

// TODO: IMPORTANT! change the "QEditorWiget*"-pointers to what is needed to identify the view!
class QEditorWidget; //DEL THIS LINE!!

/**INTERNAL**/

struct CursHistEntry {
  QEditorWidget* FileId;
  int LineCol;  // (Line 0..2^24-1) *256 + Column 0..255 to save memory
};

const int GCPH_BLOCK=7;    // num of lines within which a cursor movement is not to be stored twice
const int GCPH_HISTSZ=260; // size of history list
const int GCPH_HSTACK=16;  // size of history stack

/***BEGIN****/

/* Purpose: 
     Implements a global cursor position history 
*/
class CGlobalCursorPosHistory {
public:
    CGlobalCursorPosHistory();
    ~CGlobalCursorPosHistory();

	// store/update positions
    void CursorChanged(QEditorWidget* FileId, int line, int column);   // inform this class!
    void FileClosed(QEditorWidget* FileId);                            // clean up history list
	// get new position
	QEditorWidget* NavigateBack(int &line, int &column);     // Ctrl-Alt-Left  for example
	QEditorWidget* NavigateLeave(int &line, int &column);    // Ctrl-Alt-Up    for example
    QEditorWidget* NavigateForward(int &line, int &column);  // Ctrl-Alt-Right for example
	QEditorWidget* NavigatePop(int &line, int &column);      // Ctrl-Alt-Down  for example 


private:
    CursHistEntry* m_hist;
	CursHistEntry* m_stack;
    int num;                  // number of valid entries
	int curr;                 // entry with last known cursor position (current)
	int num_s;                // number of valid entries in stack
};


/****END*****/


#endif CURSHIST_H




More information about the KDevelop-devel mailing list