From 53d0cb6e67961639fcdc3ff1b029c5bc6a4ec902 Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Tue, 18 May 2010 00:38:40 +0000 Subject: [PATCH] 2010-15-17 17:29 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * contrib/hbqt/doc/en/class_hbqplaintextedit.txt * contrib/hbqt/hbqt_hbqplaintextedit.cpp * contrib/hbqt/hbqt_hbqplaintextedit.h * contrib/hbqt/qtgui/HBQPlainTextEdit.cpp * contrib/hbqt/qtgui/THBQPlainTextEdit.prg * contrib/hbqt/qth/HBQPlainTextEdit.qth * contrib/hbide/idedocwriter.prg % Guarded against inserting help if "readonly" flag is ON. * contrib/hbide/ideedit.prg * contrib/hbide/ideeditor.prg * contrib/hbide/ideshortcuts.prg + Added: navigational methods plus methods pertaining to line operations into public API. Naviagable methods are : ::up(), ::down(), ::pageUp(), ::pageDown(), ::goTop(), ::goBottom(), ::right(), ::left(), ::end(), ::home(), ::panEnd(), ::panHome(). // These methods can be used in combination with selection modes. + Grouped: public methods list by category which is displayed under visually distinguished colors. Now it is easy to find a method of interest easily. Before it was a literal mess. --- harbour/ChangeLog | 26 ++ harbour/contrib/hbide/idedocwriter.prg | 8 +- harbour/contrib/hbide/ideedit.prg | 107 ++++- harbour/contrib/hbide/ideeditor.prg | 100 ++++- harbour/contrib/hbide/ideshortcuts.prg | 410 ++++++++++++------ .../hbqt/doc/en/class_hbqplaintextedit.txt | 2 + .../contrib/hbqt/hbqt_hbqplaintextedit.cpp | 38 ++ harbour/contrib/hbqt/hbqt_hbqplaintextedit.h | 3 +- .../contrib/hbqt/qtgui/HBQPlainTextEdit.cpp | 30 +- .../contrib/hbqt/qtgui/THBQPlainTextEdit.prg | 10 + harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth | 3 +- 11 files changed, 594 insertions(+), 143 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 4c5ea1f614..700db9605b 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,32 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-15-17 17:29 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * contrib/hbqt/doc/en/class_hbqplaintextedit.txt + * contrib/hbqt/hbqt_hbqplaintextedit.cpp + * contrib/hbqt/hbqt_hbqplaintextedit.h + * contrib/hbqt/qtgui/HBQPlainTextEdit.cpp + * contrib/hbqt/qtgui/THBQPlainTextEdit.prg + * contrib/hbqt/qth/HBQPlainTextEdit.qth + + * contrib/hbide/idedocwriter.prg + % Guarded against inserting help if "readonly" flag is ON. + + * contrib/hbide/ideedit.prg + * contrib/hbide/ideeditor.prg + * contrib/hbide/ideshortcuts.prg + + Added: navigational methods plus methods pertaining to + line operations into public API. Naviagable methods are : + ::up(), ::down(), ::pageUp(), ::pageDown(), ::goTop(), + ::goBottom(), ::right(), ::left(), ::end(), ::home(), + ::panEnd(), ::panHome(). + // + These methods can be used in combination with selection modes. + + + Grouped: public methods list by category which is displayed + under visually distinguished colors. Now it is easy to find + a method of interest easily. Before it was a literal mess. + 2010-05-18 02:25 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * utils/hbmk2/hbmk2.pt_BR.po * utils/hbmk2/hbmk2.hu_HU.po diff --git a/harbour/contrib/hbide/idedocwriter.prg b/harbour/contrib/hbide/idedocwriter.prg index 62cf4fb4ad..c02e94ed4f 100644 --- a/harbour/contrib/hbide/idedocwriter.prg +++ b/harbour/contrib/hbide/idedocwriter.prg @@ -520,12 +520,16 @@ METHOD IdeDocWriter:saveInFile() /*----------------------------------------------------------------------*/ METHOD IdeDocWriter:saveInFunction() - LOCAL nCurLine, oEdit, txt_:= ::buildDocument() + LOCAL nCurLine, oEdit /* Bring it on top and make it current */ ::oSM:editSource( ::cSourceFile, , , , , , .f. ) IF !empty( oEdit := ::oEM:getEditObjectCurrent() ) + IF oEdit:lReadOnly + RETURN Self + ENDIF + IF oEdit:isModified() MsgBox( oEdit:oEditor:sourceFile + " is modified.", "Please save the source first!" ) RETURN Self @@ -537,7 +541,7 @@ METHOD IdeDocWriter:saveInFunction() MsgBox( "Source is modified, anyway proceeding.", "Documentation Save Alert" ) ENDIF oEdit:home() - oEdit:insertText( hbide_arrayToMemo( txt_ ) ) + oEdit:insertText( hbide_arrayToMemo( ::buildDocument() ) ) oEdit:up() oEdit:deleteLine() oEdit:qEdit:centerCursor() diff --git a/harbour/contrib/hbide/ideedit.prg b/harbour/contrib/hbide/ideedit.prg index ca60286a9c..5357a200f1 100644 --- a/harbour/contrib/hbide/ideedit.prg +++ b/harbour/contrib/hbide/ideedit.prg @@ -128,6 +128,7 @@ CLASS IdeEdit INHERIT IdeObject DATA aBlockCopyContents INIT {} DATA isLineSelectionON INIT .F. DATA aSelectionInfo INIT { -1,-1,-1,-1,1,0 } + DATA aViewportInfo INIT { -1,-1,-1,-1,-1,-1 } DATA isColumnSelectionON INIT .F. DATA lReadOnly INIT .F. @@ -192,9 +193,6 @@ CLASS IdeEdit INHERIT IdeObject METHOD setLineNumbersBkColor( nR, nG, nB ) METHOD setCurrentLineColor( nR, nG, nB ) METHOD getCursor() INLINE QTextCursor():from( ::qEdit:textCursor() ) - METHOD down() - METHOD up() - METHOD home() METHOD find( cText, nPosFrom ) METHOD refresh() METHOD isModified() INLINE ::oEditor:qDocument:isModified() @@ -210,6 +208,19 @@ CLASS IdeEdit INHERIT IdeObject METHOD dispStatusInfo() METHOD toggleCurrentLineHighlightMode() + METHOD home() + METHOD end() + METHOD down() + METHOD up() + METHOD goBottom() + METHOD goTop() + METHOD left() + METHOD right() + METHOD panEnd() + METHOD panHome() + METHOD pageUp() + METHOD pageDown() + ENDCLASS /*----------------------------------------------------------------------*/ @@ -623,6 +634,9 @@ METHOD IdeEdit:execKeyEvent( nMode, nEvent, p, p1 ) ELSEIF p == 21014 ::deleteBlockContents( p1 ) + ELSEIF p == 21017 /* Sends Block Info { t,l,b,r,mode,state } hbGetBlockInfo() */ + ::aViewportInfo := p1 + ENDIF EXIT @@ -1431,37 +1445,98 @@ METHOD IdeEdit:refresh() RETURN Self /*----------------------------------------------------------------------*/ +// TBrowse Like Navigation +/*----------------------------------------------------------------------*/ METHOD IdeEdit:home() - LOCAL qCursor := ::getCursor() + ::qEdit:hbApplyKey( Qt_Key_Home ) + RETURN Self - qCursor:movePosition( QTextCursor_StartOfBlock ) - ::qEdit:setTextCursor( qCursor ) +/*----------------------------------------------------------------------*/ +METHOD IdeEdit:end() + ::qEdit:hbApplyKey( Qt_Key_End ) RETURN Self /*----------------------------------------------------------------------*/ METHOD IdeEdit:down() - LOCAL qCursor := QTextCursor():configure( ::qEdit:textCursor() ) - - qCursor:movePosition( QTextCursor_Down ) - ::qEdit:setTextCursor( qCursor ) - + ::qEdit:hbApplyKey( Qt_Key_Down ) RETURN Self /*----------------------------------------------------------------------*/ METHOD IdeEdit:up() - LOCAL qCursor := QTextCursor():configure( ::qEdit:textCursor() ) - - qCursor:movePosition( QTextCursor_Up ) - ::qEdit:setTextCursor( qCursor ) - + ::qEdit:hbApplyKey( Qt_Key_Up ) RETURN Self /*----------------------------------------------------------------------*/ +METHOD IdeEdit:goBottom() + ::qEdit:hbApplyKey( Qt_Key_End, Qt_ControlModifier ) + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD IdeEdit:goTop() + ::qEdit:hbApplyKey( Qt_Key_Home, Qt_ControlModifier ) + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD IdeEdit:left() + ::qEdit:hbApplyKey( Qt_Key_Left ) + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD IdeEdit:right() + ::qEdit:hbApplyKey( Qt_Key_Right ) + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD IdeEdit:panEnd() + LOCAL qCursor := ::getCursor() + LOCAL cLine := ::getLine() + ::qEdit:hbGetViewportInfo() + IF len( cLine ) - ::aViewportInfo[ 2 ] > ::aViewportInfo[ 4 ] + qCursor:movePosition( QTextCursor_Right, QTextCursor_MoveAnchor, len( cLine ) - ::aViewportInfo[ 2 ] ) + ELSE + qCursor:movePosition( QTextCursor_EndOfLine ) + ENDIF + ::qEdit:setTextCursor( qCursor ) + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD IdeEdit:panHome() + LOCAL qCursor := ::getCursor() + ::qEdit:hbGetViewportInfo() + IF ::aViewportInfo[ 2 ] == 0 + qCursor:movePosition( QTextCursor_StartOfLine ) + ELSE + qCursor:movePosition( QTextCursor_Left, QTextCursor_MoveAnchor, qCursor:columnNumber() - ::aViewportInfo[ 2 ] ) + ENDIF + ::qEdit:setTextCursor( qCursor ) + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD IdeEdit:pageUp() + ::qEdit:hbApplyKey( Qt_Key_PageUp ) + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD IdeEdit:pageDown() + ::qEdit:hbApplyKey( Qt_Key_PageDown ) + RETURN Self + +/*----------------------------------------------------------------------*/ +// +/*----------------------------------------------------------------------*/ + METHOD IdeEdit:duplicateLine() ::qEdit:hbDuplicateLine() RETURN Self diff --git a/harbour/contrib/hbide/ideeditor.prg b/harbour/contrib/hbide/ideeditor.prg index 3217b4227f..35ef349613 100644 --- a/harbour/contrib/hbide/ideeditor.prg +++ b/harbour/contrib/hbide/ideeditor.prg @@ -150,6 +150,19 @@ CLASS IdeEditsManager INHERIT IdeObject METHOD gotoFunction() METHOD clearSelection() + METHOD home() + METHOD end() + METHOD down() + METHOD up() + METHOD goBottom() + METHOD goTop() + METHOD left() + METHOD right() + METHOD panEnd() + METHOD panHome() + METHOD pageUp() + METHOD pageDown() + ENDCLASS /*----------------------------------------------------------------------*/ @@ -972,7 +985,92 @@ METHOD IdeEditsManager:goto( nLine ) ENDIF RETURN nLine - +/*----------------------------------------------------------------------*/ +// Navigation +/*----------------------------------------------------------------------*/ +METHOD IdeEditsManager:home() + LOCAL oEdit + IF !empty( oEdit := ::getEditObjectCurrent() ) + oEdit:home() + ENDIF + RETURN Self +/*----------------------------------------------------------------------*/ +METHOD IdeEditsManager:end() + LOCAL oEdit + IF !empty( oEdit := ::getEditObjectCurrent() ) + oEdit:end() + ENDIF + RETURN Self +/*----------------------------------------------------------------------*/ +METHOD IdeEditsManager:down() + LOCAL oEdit + IF !empty( oEdit := ::getEditObjectCurrent() ) + oEdit:down() + ENDIF + RETURN Self +/*----------------------------------------------------------------------*/ +METHOD IdeEditsManager:up() + LOCAL oEdit + IF !empty( oEdit := ::getEditObjectCurrent() ) + oEdit:up() + ENDIF + RETURN Self +/*----------------------------------------------------------------------*/ +METHOD IdeEditsManager:goBottom() + LOCAL oEdit + IF !empty( oEdit := ::getEditObjectCurrent() ) + oEdit:goBottom() + ENDIF + RETURN Self +/*----------------------------------------------------------------------*/ +METHOD IdeEditsManager:goTop() + LOCAL oEdit + IF !empty( oEdit := ::getEditObjectCurrent() ) + oEdit:goTop() + ENDIF + RETURN Self +/*----------------------------------------------------------------------*/ +METHOD IdeEditsManager:left() + LOCAL oEdit + IF !empty( oEdit := ::getEditObjectCurrent() ) + oEdit:left() + ENDIF + RETURN Self +/*----------------------------------------------------------------------*/ +METHOD IdeEditsManager:right() + LOCAL oEdit + IF !empty( oEdit := ::getEditObjectCurrent() ) + oEdit:right() + ENDIF + RETURN Self +/*----------------------------------------------------------------------*/ +METHOD IdeEditsManager:panEnd() + LOCAL oEdit + IF !empty( oEdit := ::getEditObjectCurrent() ) + oEdit:panEnd() + ENDIF + RETURN Self +/*----------------------------------------------------------------------*/ +METHOD IdeEditsManager:panHome() + LOCAL oEdit + IF !empty( oEdit := ::getEditObjectCurrent() ) + oEdit:panHome() + ENDIF + RETURN Self +/*----------------------------------------------------------------------*/ +METHOD IdeEditsManager:pageUp() + LOCAL oEdit + IF !empty( oEdit := ::getEditObjectCurrent() ) + oEdit:pageUp() + ENDIF + RETURN Self +/*----------------------------------------------------------------------*/ +METHOD IdeEditsManager:pageDown() + LOCAL oEdit + IF !empty( oEdit := ::getEditObjectCurrent() ) + oEdit:pageDown() + ENDIF + RETURN Self /*----------------------------------------------------------------------*/ // // CLASS IdeEditor diff --git a/harbour/contrib/hbide/ideshortcuts.prg b/harbour/contrib/hbide/ideshortcuts.prg index 824ce6cf04..5b85212e5a 100644 --- a/harbour/contrib/hbide/ideshortcuts.prg +++ b/harbour/contrib/hbide/ideshortcuts.prg @@ -204,6 +204,19 @@ CLASS IdeShortcuts INHERIT IdeObject METHOD clearSelection() METHOD execPlugin( cPlugin, ... ) METHOD toggleCurrentLineHilight() + /* Navigation */ + METHOD home() + METHOD end() + METHOD down() + METHOD up() + METHOD goBottom() + METHOD goTop() + METHOD left() + METHOD right() + METHOD panEnd() + METHOD panHome() + METHOD pageUp() + METHOD pageDown() ENDCLASS @@ -369,8 +382,10 @@ METHOD IdeShortcuts:execEvent( nMode, p ) CASE listMethods_itemDoubleClicked IF ( nRow := ::oUI:q_listMethods:currentRow() ) >= 0 nRow++ - cMethod := "::" + ::aMethods[ nRow, 2 ] - ::oUI:q_plainBlock:insertPlainText( cMethod ) + IF !empty( ::aMethods[ nRow, 2 ] ) + cMethod := "::" + ::aMethods[ nRow, 2 ] + ::oUI:q_plainBlock:insertPlainText( cMethod ) + ENDIF ENDIF EXIT CASE listMethods_currentRowChanged @@ -637,7 +652,15 @@ METHOD IdeShortcuts:populateMethods() FOR EACH a_ IN ::aMethods IF !empty( a_[ 1 ] ) qItem := QListWidgetItem():new() - qItem:setText( a_[ 1 ] ) + + IF left( a_[ 1 ], 1 ) == " " + qItem:setText( alltrim( a_[ 1 ] ) ) + qItem:setForeground( QBrush():new( "QColor", QColor():new( 255,0,0 ) ) ) + qItem:setBackground( QBrush():new( "QColor", QColor():new( 255,255,200 ) ) ) + qItem:setTextAlignment( Qt_AlignHCenter ) + ELSE + qItem:setText( a_[ 1 ] ) + ENDIF aadd( ::aMtdItms, qItem ) qLW:addItem_1( qItem ) ENDIF @@ -1135,15 +1158,133 @@ METHOD IdeShortcuts:toggleLineSelectionMode() METHOD IdeShortcuts:clearSelection() RETURN ::oEM:clearSelection() /*----------------------------------------------------------------------*/ +// Navigation +/*----------------------------------------------------------------------*/ +METHOD IdeShortcuts:home() + RETURN ::oEM:home() +/*----------------------------------------------------------------------*/ +METHOD IdeShortcuts:end() + RETURN ::oEM:end() +/*----------------------------------------------------------------------*/ +METHOD IdeShortcuts:down() + RETURN ::oEM:down() +/*----------------------------------------------------------------------*/ +METHOD IdeShortcuts:up() + RETURN ::oEM:up() +/*----------------------------------------------------------------------*/ +METHOD IdeShortcuts:goBottom() + RETURN ::oEM:goBottom() +/*----------------------------------------------------------------------*/ +METHOD IdeShortcuts:goTop() + RETURN ::oEM:goTop() +/*----------------------------------------------------------------------*/ +METHOD IdeShortcuts:left() + RETURN ::oEM:left() +/*----------------------------------------------------------------------*/ +METHOD IdeShortcuts:right() + RETURN ::oEM:right() +/*----------------------------------------------------------------------*/ +METHOD IdeShortcuts:panEnd() + RETURN ::oEM:panEnd() +/*----------------------------------------------------------------------*/ +METHOD IdeShortcuts:panHome() + RETURN ::oEM:panHome() +/*----------------------------------------------------------------------*/ +METHOD IdeShortcuts:pageUp() + RETURN ::oEM:pageUp() +/*----------------------------------------------------------------------*/ +METHOD IdeShortcuts:pageDown() + RETURN ::oEM:pageDown() +/*----------------------------------------------------------------------*/ +// Public API Definitions +/*----------------------------------------------------------------------*/ METHOD IdeShortcuts:loadMethods() + aadd( ::aMethods, { ' General', ; + '', ; + 'General API Methods follow.' } ) + //........................................................// aadd( ::aMethods, { 'help( cTopic )', ; 'help( "" )', ; 'Invokes "Help" docking widget in the right docking area. is not active yet.' } ) aadd( ::aMethods, { 'exit( lWarn )', ; 'exit( .f. )', ; 'Exits hbIDE. If then confirmation is requested through a popup dialog. All sources are saved if in modified state after confirmation to do so.' } ) + aadd( ::aMethods, { 'execTool( cName )' , ; + 'execTool( "" )' , ; + 'Executes a Tool defined and visible under tools menu.' } ) + aadd( ::aMethods, { 'execTool( cCmd, cParams, cStartIn, lCapture, lShowOutput )' , ; + 'execTool( "", "", "", .f., .f. )', ; + 'Executes a program or file with parameters and other attributes.' + CRLF + ; + 'http://hbide.vouch.info/ ( Topic: Tools and Utilities )' } ) + aadd( ::aMethods, { 'execPlugin( cPlugin )', ; + 'execPlugin( "" )', ; + 'Attempts to execute third-party plugins. First parameter passed is the instance to SELF exposing public API methods. Next parameters are passes as a list.' } ) + aadd( ::aMethods, { 'setBookMark()' , ; + 'setBookMark()' , ; + 'Attempts to install a bookmark onto current cursor position. If successful, mark appears as a colored tool-button on the statusbar and marked line is highlighted with the same color.' } ) + aadd( ::aMethods, { 'gotoMark( nMark )' , ; + 'gotoMark( 1 )' , ; + 'Attempts to reach mark represented by . Please note maximum 6 bookmarks are avialable per edit instance.' } ) + aadd( ::aMethods, { 'setView( cView )' , ; + 'setView( "" )' , ; + 'Brings panel to front. Defaults to "Stats", i.e., tab.' } ) + aadd( ::aMethods, { 'presentSkeletons()', ; + 'presentSkeletons()', ; + 'Present snippets for selection.' } ) + aadd( ::aMethods, { 'gotoFunction()', ; + 'gotoFunction()', ; + 'Takes under-cursor word and attempts to open the source containing that function in a new tab.' } ) + + aadd( ::aMethods, { ' Navigation', ; + '', ; + 'Navigation API Methods follow.' } ) + //........................................................// + aadd( ::aMethods, { 'down()', ; + 'down()', ; + 'Cursor is positioned one row down.' } ) + aadd( ::aMethods, { 'up()', ; + 'up()', ; + 'Cursor is positioned one row up.' } ) + aadd( ::aMethods, { 'pageDown()', ; + 'pageDown()', ; + 'Cursor is positioned one page down.' } ) + aadd( ::aMethods, { 'pageUp()', ; + 'pageUp()', ; + 'Cursor is positioned one page up.' } ) + aadd( ::aMethods, { 'goBottom()', ; + 'goBottom()', ; + 'Cursor is positioned at the end of the source.' } ) + aadd( ::aMethods, { 'goTop()', ; + 'goTop()', ; + 'Cursor is positioned at the begining of the source.' } ) + aadd( ::aMethods, { 'right()', ; + 'right()', ; + 'Cursor is positioned one character to the right. If there is no character to the right in current line, cursor is positioned on next line, character 0.' } ) + aadd( ::aMethods, { 'left()', ; + 'left()', ; + 'Cursor is positioned one character to the left. If there is no character to the left in current line, cursor is positioned on previous line, last character.' } ) + aadd( ::aMethods, { 'end()', ; + 'end()', ; + 'Cursor is positioned at the right-most column.' } ) + aadd( ::aMethods, { 'home()', ; + 'home()', ; + 'Cursor is positioned at the left-most column.' } ) + aadd( ::aMethods, { 'panEnd()', ; + 'panEnd()', ; + 'Cursor is positioned last visible column in the viewport.' } ) + aadd( ::aMethods, { 'panHome()', ; + 'panHome()', ; + 'Cursor is positioned first visible column in the viewport.' } ) + aadd( ::aMethods, { 'gotoLine( nLine )', ; + 'gotoLine( )', ; + 'Attempt is made to position the cursor at . If is not supplied, a "Goto" dialog is opened to supply .' } ) + + aadd( ::aMethods, { ' Files', ; + '', ; + 'Files API Methods follow.' } ) + //........................................................// aadd( ::aMethods, { 'newSource( cType )', ; 'newSource( "" )', ; 'Initiates a blank source file in an editing instance on the current panel.' } ) @@ -1165,82 +1306,11 @@ METHOD IdeShortcuts:loadMethods() aadd( ::aMethods, { 'print()', ; 'print()', ; 'Invokes "Print Preview" dialog with current source contents ready to be printed.' } ) - aadd( ::aMethods, { 'findDlg()', ; - 'findDlg()', ; - 'Invokes "Find and Replace" dialog.' } ) - aadd( ::aMethods, { 'findAgain()', ; - 'findAgain()', ; - 'Finds last search string without opening the dialog.' } ) - aadd( ::aMethods, { 'replace()', ; - 'replace()', ; - 'Replaces last replace string if some text is already selected without opening the dialog.' } ) - aadd( ::aMethods, { 'findDlgEx()', ; - 'findDlgEx()', ; - 'Invokes extended "Find and Replace" dialog at the bottom of editing area.' } ) - aadd( ::aMethods, { 'gotoLine( nLine )', ; - 'gotoLine( )', ; - 'Attempt is made to position the cursor at . If is not supplied, a "Goto" dialog is opened to supply .' } ) - aadd( ::aMethods, { 'indentRight()', ; - 'indentRight()', ; - 'Pushes one character right the currently selected text.' } ) - aadd( ::aMethods, { 'indentLeft()', ; - 'indentLeft()', ; - 'Pushes one character left the currently selected text. If there are no columns remains at left nothing happens.' } ) - aadd( ::aMethods, { 'blockComment()', ; - 'blockComment()', ; - 'Encloses currently selected text in line comments where each line is prefixed with //.' } ) - aadd( ::aMethods, { 'streamComment()', ; - 'streamComment()', ; - 'Encloses currently selected text in Anci-C like comments /* */' } ) - aadd( ::aMethods, { 'toUpper()', ; - 'toUpper()', ; - 'Converts currently selected text to upper-case.' } ) - aadd( ::aMethods, { 'toLower()', ; - 'toLower()', ; - 'Converts currently selected text to lower-case.' } ) - aadd( ::aMethods, { 'invertCase()', ; - 'invertCase()', ; - 'Inverts case of currently selected text: upper => lower; lower => upper.' } ) - aadd( ::aMethods, { 'build( cProj )', ; - 'build( "" )', ; - 'Builds if it is already loaded. All sources are saved if found in modified state before "build" is initiated.' } ) - aadd( ::aMethods, { 'buildLaunch( cProj )', ; - 'buildLaunch( "" )', ; - 'Builds and launches if it is already loaded. All sources are saved if found in modified state before "build" is initiated.' } ) - aadd( ::aMethods, { 'reBuild( cProj )', ; - 'reBuild( "" )', ; - 'Re-builds if it is already loaded. All sources are saved if found in modified state before "build" is initiated.' } ) - aadd( ::aMethods, { 'reBuildLaunch( cProj )', ; - 'reBuildLaunch( "" )', ; - 'Re-builds and launches if it is already loaded. All sources are saved if found in modified state before "build" is initiated.' } ) - aadd( ::aMethods, { 'launch( cProj )' , ; - 'launch( "" )' , ; - 'Launches if it is already loaded.' } ) - aadd( ::aMethods, { 'insert( cText )' , ; - 'insert( "" )' , ; - 'Insert at current cursor position.' } ) - aadd( ::aMethods, { 'separator( cSep )' , ; - 'separator( ' + '/*' + replicate( "-", 68 ) + '*/' + ' )', ; - 'Inserts separator line immediately before current line. defaults to "/*---*/"' } ) - aadd( ::aMethods, { 'getWord( lSelect )', ; - 'getWord( .f. )' , ; - 'Returns text of the word under cursor. If text appears as selected.' } ) - aadd( ::aMethods, { 'getLine( lSelect )', ; - 'getLine( .f. )' , ; - 'Returns text of the current line. If text appears as selected.' } ) - aadd( ::aMethods, { 'getText()' , ; - 'getText()' , ; - 'Returns current selected text.' } ) - aadd( ::aMethods, { 'execTool( cName )' , ; - 'execTool( "" )' , ; - 'Executes a Tool defined and visible under tools menu.' } ) - aadd( ::aMethods, { 'execTool( cCmd, cParams, cStartIn, lCapture, lShowOutput )' , ; - 'execTool( "", "", "", .f., .f. )', ; - 'Executes a program or file with parameters and other attributes.' + CRLF + ; - 'http://hbide.vouch.info/ ( Topic: Tools and Utilities )' } ) - aadd( ::aMethods, { 'zoom( nVal )' , ; - 'zoom( +1 )' , ; - 'Zooms in/out the current editing instance. nVal: 1-one size up; -1-one size less; NIL-original size; 5~30-to size.' } ) + + aadd( ::aMethods, { ' Edit', ; + '', ; + 'Edit API Methods follow.' } ) + //........................................................// aadd( ::aMethods, { 'cut()' , ; 'cut()' , ; 'Cuts the selected text and copies onto clipboard.' } ) @@ -1262,42 +1332,128 @@ METHOD IdeShortcuts:loadMethods() aadd( ::aMethods, { 'print()' , ; 'print()' , ; 'Opens Print Preview dialog which will contain the source line broken by pages.' } ) - aadd( ::aMethods, { 'setBookMark()' , ; - 'setBookMark()' , ; - 'Attempts to install a bookmark onto current cursor position. If successful, mark appears as a colored tool-button on the statusbar and marked line is highlighted with the same color.' } ) - aadd( ::aMethods, { 'gotoMark( nMark )' , ; - 'gotoMark( 1 )' , ; - 'Attempts to reach mark represented by . Please note maximum 6 bookmarks are avialable per edit instance.' } ) - aadd( ::aMethods, { 'switchToReadOnly()', ; - 'switchToReadOnly()', ; - 'Flags current editing instance read-only.' } ) - aadd( ::aMethods, { 'dlgKeyboardMappings()', ; - 'dlgKeyboardMappings()', ; - 'Opens "Keyboard Mappings" dialog.' } ) - aadd( ::aMethods, { 'dlgToolsAndUtils()', ; - 'dlgToolsAndUtils()', ; - 'Opens "Toola & Utilities" dialog.' } ) - aadd( ::aMethods, { 'setView( cView )' , ; - 'setView( "" )' , ; - 'Brings panel to front. Defaults to "Stats", i.e., tab.' } ) - aadd( ::aMethods, { 'compilePPO()' , ; - 'compilePPO()' , ; - 'Attemps to compile current source to .ppo formats, and if successful, presents the compiled source in a new edit instance.' } ) - aadd( ::aMethods, { 'single2doubleQuotes()', ; - 'single2doubleQuotes()', ; - 'Converts single quotes to double in the currently selected text.' } ) - aadd( ::aMethods, { 'double2singleQuotes()', ; - 'double2singleQuotes()', ; - 'Converts double quotes to single in the currently selected text.' } ) + aadd( ::aMethods, { 'findDlg()', ; + 'findDlg()', ; + 'Invokes "Find and Replace" dialog.' } ) + aadd( ::aMethods, { 'findAgain()', ; + 'findAgain()', ; + 'Finds last search string without opening the dialog.' } ) + aadd( ::aMethods, { 'replace()', ; + 'replace()', ; + 'Replaces last replace string if some text is already selected without opening the dialog.' } ) + aadd( ::aMethods, { 'findDlgEx()', ; + 'findDlgEx()', ; + 'Invokes extended "Find and Replace" dialog at the bottom of editing area.' } ) + aadd( ::aMethods, { 'insert( cText )' , ; + 'insert( "" )' , ; + 'Insert at current cursor position.' } ) + aadd( ::aMethods, { 'separator( cSep )' , ; + 'separator( ' + '/*' + replicate( "-", 68 ) + '*/' + ' )', ; + 'Inserts separator line immediately before current line. defaults to "/*---*/"' } ) aadd( ::aMethods, { 'tabs2spaces()', ; 'tabs2spaces()', ; 'Converts tabs to spaces, currently 3, the entire source. However, source is not saved.' } ) aadd( ::aMethods, { 'removeTrailingSpaces()', ; 'removeTrailingSpaces()', ; 'Removes trailing spaces per line, the entire source. However, source is not saved.' } ) + aadd( ::aMethods, { 'switchToReadOnly()', ; + 'switchToReadOnly()', ; + 'Flags current editing instance read-only.' } ) + + aadd( ::aMethods, { ' Line Operations', ; + '', ; + 'Line API Methods follow.' } ) + //........................................................// + aadd( ::aMethods, { 'duplicateLine()', ; + 'duplicateLine()', ; + 'Duplicates current line.' } ) + aadd( ::aMethods, { 'deleteLine()', ; + 'deleteLine()', ; + 'Deletes current line.' } ) + aadd( ::aMethods, { 'moveLineUp()', ; + 'moveLineUp()', ; + 'Moves current line up.' } ) + aadd( ::aMethods, { 'moveLineDown()', ; + 'moveLineDown()', ; + 'Moves current line down.' } ) + + aadd( ::aMethods, { ' Display Attributes', ; + '', ; + 'Display API Methods follow.' } ) + //........................................................// + aadd( ::aMethods, { 'zoom( nVal )' , ; + 'zoom( +1 )' , ; + 'Zooms in/out the current editing instance. nVal: 1-one size up; -1-one size less; NIL-original size; 5~30-to size.' } ) aadd( ::aMethods, { 'toggleLineNumbersDisplay()', ; 'toggleLineNumbersDisplay()', ; 'Toggles line numbers display inside editing instances. This action has global scope and is saved for next run.' } ) + aadd( ::aMethods, { 'toggleCurrentLineHilight()', ; + 'toggleCurrentLineHilight()', ; + 'Toggles the mode to highlight current line or not in the editor. The effect is global. Setting is not retained for next run' } ) + aadd( ::aMethods, { 'toggleStatusBar()', ; + 'toggleStatusBar()', ; + 'Toggles display of statusbar. The action is not saved for next run.' } ) + + aadd( ::aMethods, { ' Block Operations', ; + '', ; + 'Blocks API Methods follow.' } ) + //........................................................// + aadd( ::aMethods, { 'indentRight()', ; + 'indentRight()', ; + 'Pushes one character right the currently selected text.' } ) + aadd( ::aMethods, { 'indentLeft()', ; + 'indentLeft()', ; + 'Pushes one character left the currently selected text. If there are no columns remains at left nothing happens.' } ) + aadd( ::aMethods, { 'blockComment()', ; + 'blockComment()', ; + 'Encloses currently selected text in line comments where each line is prefixed with //.' } ) + aadd( ::aMethods, { 'streamComment()', ; + 'streamComment()', ; + 'Encloses currently selected text in Anci-C like comments /* */' } ) + aadd( ::aMethods, { 'toUpper()', ; + 'toUpper()', ; + 'Converts currently selected text to upper-case.' } ) + aadd( ::aMethods, { 'toLower()', ; + 'toLower()', ; + 'Converts currently selected text to lower-case.' } ) + aadd( ::aMethods, { 'invertCase()', ; + 'invertCase()', ; + 'Inverts case of currently selected text: upper => lower; lower => upper.' } ) + aadd( ::aMethods, { 'single2doubleQuotes()', ; + 'single2doubleQuotes()', ; + 'Converts single quotes to double in the currently selected text.' } ) + aadd( ::aMethods, { 'double2singleQuotes()', ; + 'double2singleQuotes()', ; + 'Converts double quotes to single in the currently selected text.' } ) + + + aadd( ::aMethods, { ' Projects', ; + '', ; + 'Projects API Methods follow.' } ) + //........................................................// + aadd( ::aMethods, { 'build( cProj )', ; + 'build( "" )', ; + 'Builds if it is already loaded. All sources are saved if found in modified state before "build" is initiated.' } ) + aadd( ::aMethods, { 'buildLaunch( cProj )', ; + 'buildLaunch( "" )', ; + 'Builds and launches if it is already loaded. All sources are saved if found in modified state before "build" is initiated.' } ) + aadd( ::aMethods, { 'reBuild( cProj )', ; + 'reBuild( "" )', ; + 'Re-builds if it is already loaded. All sources are saved if found in modified state before "build" is initiated.' } ) + aadd( ::aMethods, { 'reBuildLaunch( cProj )', ; + 'reBuildLaunch( "" )', ; + 'Re-builds and launches if it is already loaded. All sources are saved if found in modified state before "build" is initiated.' } ) + aadd( ::aMethods, { 'launch( cProj )' , ; + 'launch( "" )' , ; + 'Launches if it is already loaded.' } ) + aadd( ::aMethods, { 'compilePPO()' , ; + 'compilePPO()' , ; + 'Attemps to compile current source to .ppo formats, and if successful, presents the compiled source in a new edit instance.' } ) + + aadd( ::aMethods, { ' Selections', ; + '', ; + 'Selections API Methods follow.' } ) + //........................................................// aadd( ::aMethods, { 'toggleColumnSelectionMode()', ; 'toggleColumnSelectionMode()', ; 'Toggles selection mode from "stream" to "column" or vice-versa.' } ) @@ -1307,21 +1463,33 @@ METHOD IdeShortcuts:loadMethods() aadd( ::aMethods, { 'clearSelection()', ; 'clearSelection()', ; 'Clears the selection block, if any, and resets the selection mode to stream.' } ) - aadd( ::aMethods, { 'toggleStatusBar()', ; - 'toggleStatusBar()', ; - 'Toggles display of statusbar. The action is not saved for next run.' } ) - aadd( ::aMethods, { 'presentSkeletons()', ; - 'presentSkeletons()', ; - 'Present snippets for selection.' } ) - aadd( ::aMethods, { 'gotoFunction()', ; - 'gotoFunction()', ; - 'Takes under-cursor word and attempts to open the source containing that function in a new tab.' } ) - aadd( ::aMethods, { 'execPlugin( cPlugin )', ; - 'execPlugin( "" )', ; - 'Attempts to execute third-party plugins. First parameter passed is the instance to SELF exposing public API methods. Next parameters are passes as a list.' } ) - aadd( ::aMethods, { 'toggleCurrentLineHilight()', ; - 'toggleCurrentLineHilight()', ; - 'Toggles the mode to highlight current line or not in the editor. The effect is global. Setting is not retained for next run' } ) + + + aadd( ::aMethods, { ' Retreivals', ; + '', ; + 'Text Retreival API Methods follow.' } ) + //........................................................// + aadd( ::aMethods, { 'getWord( lSelect )', ; + 'getWord( .f. )' , ; + 'Returns text of the word under cursor. If text appears as selected.' } ) + aadd( ::aMethods, { 'getLine( lSelect )', ; + 'getLine( .f. )' , ; + 'Returns text of the current line. If text appears as selected.' } ) + aadd( ::aMethods, { 'getText()' , ; + 'getText()' , ; + 'Returns current selected text.' } ) + + + aadd( ::aMethods, { ' Activating Dialogs', ; + '', ; + 'Dialog API Methods follow.' } ) + //........................................................// + aadd( ::aMethods, { 'dlgKeyboardMappings()', ; + 'dlgKeyboardMappings()', ; + 'Opens "Keyboard Mappings" dialog.' } ) + aadd( ::aMethods, { 'dlgToolsAndUtils()', ; + 'dlgToolsAndUtils()', ; + 'Opens "Toola & Utilities" dialog.' } ) RETURN Self diff --git a/harbour/contrib/hbqt/doc/en/class_hbqplaintextedit.txt b/harbour/contrib/hbqt/doc/en/class_hbqplaintextedit.txt index 3091dac9f7..436ab09801 100644 --- a/harbour/contrib/hbqt/doc/en/class_hbqplaintextedit.txt +++ b/harbour/contrib/hbqt/doc/en/class_hbqplaintextedit.txt @@ -73,6 +73,8 @@ :hbSetSelectionInfo( xSelectionInfo ) -> NIL :hbSetSelectionColor( pColor ) -> NIL :hbSetMatchBraces( lAll ) -> NIL + :hbGetViewportInfo() -> NIL + :hbApplyKey( nKey, nModifiers, cTxt ) -> NIL $DESCRIPTION$ diff --git a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp index 96f61c9c5e..27ded28cb4 100644 --- a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp +++ b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp @@ -167,6 +167,14 @@ void HBQPlainTextEdit::hbSetEventBlock( PHB_ITEM pBlock ) /*----------------------------------------------------------------------*/ +void HBQPlainTextEdit::hbApplyKey( int key, Qt::KeyboardModifiers modifiers, const QString & txt ) +{ + QKeyEvent * ev = new QKeyEvent( QEvent::KeyPress, key, modifiers, txt ); + QPlainTextEdit::keyPressEvent( ev ); +} + +/*----------------------------------------------------------------------*/ + void HBQPlainTextEdit::hbRefresh() { repaint(); @@ -295,6 +303,36 @@ void HBQPlainTextEdit::hbClearSelection() /*----------------------------------------------------------------------*/ +void HBQPlainTextEdit::hbGetViewportInfo() +{ + if( block ) + { + PHB_ITEM p1 = hb_itemPutNI( NULL, 21017 ); + PHB_ITEM p2 = hb_itemNew( NULL ); + + hb_arrayNew( p2, 6 ); + + QTextCursor ct = cursorForPosition( QPoint( 2,2 ) ); + int t = ct.blockNumber(); + int c = ct.columnNumber(); + int rows = viewport()->height() / fontMetrics().height(); + int cols = viewport()->width() / fontMetrics().averageCharWidth(); + + hb_arraySetNI( p2, 1, t ); + hb_arraySetNI( p2, 2, c ); + hb_arraySetNI( p2, 3, rows ); + hb_arraySetNI( p2, 4, cols ); + hb_arraySetNI( p2, 5, textCursor().blockNumber() ); + hb_arraySetNI( p2, 6, textCursor().columnNumber() ); + + hb_vmEvalBlockV( block, 2, p1, p2 ); + hb_itemRelease( p1 ); + hb_itemRelease( p2 ); + } +} + +/*----------------------------------------------------------------------*/ + void HBQPlainTextEdit::hbSetSelectionInfo( PHB_ITEM selectionInfo ) { rowBegins = hb_arrayGetNI( selectionInfo, 1 ); diff --git a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h index 8086e83fd5..1753a32ce0 100644 --- a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h +++ b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h @@ -196,7 +196,8 @@ public slots: void hbSetSelectionInfo( PHB_ITEM selectionInfo ); void hbSetSelectionColor( const QColor & color ); void hbSetMatchBraces( bool all ){ m_matchBracesAll = all; }; - + void hbGetViewportInfo(); + void hbApplyKey( int key, Qt::KeyboardModifiers modifiers = 0, const QString & txt = "" ); private slots: void hbSlotCursorPositionChanged(); diff --git a/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp b/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp index 1f5ef89fb4..7617507d3b 100644 --- a/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp +++ b/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp @@ -72,7 +72,7 @@ #include "../hbqt_hbqplaintextedit.h" /* - * HBQPlainTextEdit ( QWidget * parent = 0 ) . + * HBQPlainTextEdit ( QWidget * parent = 0 ) * HBQPlainTextEdit ( const QString & text, QWidget * parent = 0 ) * virtual ~HBQPlainTextEdit () */ @@ -790,6 +790,34 @@ HB_FUNC( QT_HBQPLAINTEXTEDIT_HBSETMATCHBRACES ) } } +/* + * void hbGetViewportInfo() + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_HBGETVIEWPORTINFO ) +{ + HBQPlainTextEdit * p = hbqt_par_HBQPlainTextEdit( 1 ); + if( p ) + ( p )->hbGetViewportInfo(); + else + { + HB_TRACE( HB_TR_DEBUG, ( "............................... F=QT_HBQPLAINTEXTEDIT_HBGETVIEWPORTINFO FP=( p )->hbGetViewportInfo(); p is NULL" ) ); + } +} + +/* + * void hbApplyKey( int key, Qt::KeyboardModifiers modifiers = 0, const QString & txt ) + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_HBAPPLYKEY ) +{ + HBQPlainTextEdit * p = hbqt_par_HBQPlainTextEdit( 1 ); + if( p ) + ( p )->hbApplyKey( hb_parni( 2 ), ( Qt::KeyboardModifiers ) hb_parni( 3 ), HBQPlainTextEdit::tr( hb_parc( 4 ) ) ); + else + { + HB_TRACE( HB_TR_DEBUG, ( "............................... F=QT_HBQPLAINTEXTEDIT_HBAPPLYKEY FP=( p )->hbApplyKey( hb_parni( 2 ), ( Qt::KeyboardModifiers ) hb_parni( 3 ), HBQPlainTextEdit::tr( hb_parc( 4 ) ) ); p is NULL" ) ); + } +} + /*----------------------------------------------------------------------*/ #endif /* #if QT_VERSION >= 0x040500 */ diff --git a/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg b/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg index 23653e41bf..cdc10e53c3 100644 --- a/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg +++ b/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg @@ -112,6 +112,8 @@ CREATE CLASS HBQPlainTextEdit INHERIT HbQtObjectHandler, QPlainTextEdit METHOD hbSetSelectionInfo( xSelectionInfo ) METHOD hbSetSelectionColor( pColor ) METHOD hbSetMatchBraces( lAll ) + METHOD hbGetViewportInfo() + METHOD hbApplyKey( nKey, nModifiers, cTxt ) ENDCLASS @@ -304,3 +306,11 @@ METHOD HBQPlainTextEdit:hbSetSelectionColor( pColor ) METHOD HBQPlainTextEdit:hbSetMatchBraces( lAll ) RETURN Qt_HBQPlainTextEdit_hbSetMatchBraces( ::pPtr, lAll ) + +METHOD HBQPlainTextEdit:hbGetViewportInfo() + RETURN Qt_HBQPlainTextEdit_hbGetViewportInfo( ::pPtr ) + + +METHOD HBQPlainTextEdit:hbApplyKey( nKey, nModifiers, cTxt ) + RETURN Qt_HBQPlainTextEdit_hbApplyKey( ::pPtr, nKey, nModifiers, cTxt ) + diff --git a/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth b/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth index a1a92b954c..ce1cc3c3e2 100644 --- a/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth +++ b/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth @@ -143,7 +143,8 @@ HB_FUNC( QT_HBQPLAINTEXTEDIT ) void hbSetSelectionInfo( PHB_ITEM selectionInfo ) void hbSetSelectionColor( const QColor & color ) void hbSetMatchBraces( bool all ) - + void hbGetViewportInfo() + void hbApplyKey( int key, Qt::KeyboardModifiers modifiers = 0, const QString & txt )