2010-17:24 07:29 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)

* contrib/hbide/plugins/savebackup.hrb
  * contrib/hbide/plugins/savebackup.prg
    ! Fine tuned to receive correct number of parameters.

  * 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/hbide.prg
  * contrib/hbide/idedocks.prg
    + Added Icon: Toggle current Line Highlight in "Lines" toolbar.
      Public API method is ::toggleCurrentLineHilight().

  * contrib/hbide/ideedit.prg
  * contrib/hbide/ideeditor.prg
  * contrib/hbide/ideenviron.prg
    ! Reverted: line edits font - monospace to GUI.

  * contrib/hbide/ideobject.prg
  * contrib/hbide/ideplugins.prg
    ! tuned to send oIDE and cVer as first and second 
      argument to {plugin}_init( oIde, cVer ).

  * contrib/hbide/ideprojmanager.prg
    ! Reverted: line edits font - monospace to GUI.

  * contrib/hbide/ideshortcuts.prg
    + Public Method - ::toggleCurrentLineHilight().
      Toggles displaying current line in distinct color.

  * contrib/hbide/idethemes.prg
    + Activated: Selection Background slot.
      It facilitates to control the color of selections per theme basis.

    + Prepared to toggle matching braces mode - both vs single.
      "Setup" dialog will contain its place holder.

    % Fixed many other artifacts coming into way, and possibly
      might have broken a few ones, please report.
This commit is contained in:
Pritpal Bedi
2010-05-12 00:41:24 +00:00
parent 9d13008427
commit 51f3437a79
19 changed files with 264 additions and 97 deletions

View File

@@ -17,6 +17,50 @@
past entries belonging to author(s): Viktor Szakats.
*/
2010-17:24 07:29 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
* contrib/hbide/plugins/savebackup.hrb
* contrib/hbide/plugins/savebackup.prg
! Fine tuned to receive correct number of parameters.
* 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/hbide.prg
* contrib/hbide/idedocks.prg
+ Added Icon: Toggle current Line Highlight in "Lines" toolbar.
Public API method is ::toggleCurrentLineHilight().
* contrib/hbide/ideedit.prg
* contrib/hbide/ideeditor.prg
* contrib/hbide/ideenviron.prg
! Reverted: line edits font - monospace to GUI.
* contrib/hbide/ideobject.prg
* contrib/hbide/ideplugins.prg
! tuned to send oIDE and cVer as first and second
argument to {plugin}_init( oIde, cVer ).
* contrib/hbide/ideprojmanager.prg
! Reverted: line edits font - monospace to GUI.
* contrib/hbide/ideshortcuts.prg
+ Public Method - ::toggleCurrentLineHilight().
Toggles displaying current line in distinct color.
* contrib/hbide/idethemes.prg
+ Activated: Selection Background slot.
It facilitates to control the color of selections per theme basis.
+ Prepared to toggle matching braces mode - both vs single.
"Setup" dialog will contain its place holder.
% Fixed many other artifacts coming into way, and possibly
might have broken a few ones, please report.
2010-05-12 02:26 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/external/minizip/ioapi.h
! fixed FreeBSD and HAIKU builds

View File

@@ -227,6 +227,7 @@ CLASS HbIde
DATA lTabCloseRequested INIT .f.
DATA isColumnSelectionEnabled INIT .f.
DATA lLineNumbersVisible INIT .t.
DATA lCurrentLineHighlightEnabled INIT .t.
DATA cWrkProject INIT ""
DATA cWrkTheme INIT ""
@@ -490,7 +491,9 @@ METHOD HbIde:create( aParams )
/* Load tags last tagged projects */
::oFN:loadTags( ::aINI[ INI_TAGGEDPROJECTS ] )
/* hbide_loadPlugins() */
#if 0 /* Can be controlled through setup */
hbide_loadPlugins( Self, "1.0" )
#endif
DO WHILE .t.
::nEvent := AppEvent( @::mp1, @::mp2, @::oXbp )

View File

@@ -506,13 +506,13 @@ METHOD IdeDocks:buildToolBarPanels()
::oDlg:oWidget:addToolBar( Qt_LeftToolBarArea, ::qTBarLines )
aBtns := {}
aadd( aBtns, { "movelineup" , "Move Current Line Up" , {|| ::oEM:moveLine( -1 ) } } )
aadd( aBtns, { "movelinedown" , "Move Current Line Down" , {|| ::oEM:moveLine( 1 ) } } )
aadd( aBtns, { "deleteline" , "Delete Current Line" , {|| ::oEM:deleteLine() } } )
aadd( aBtns, { "duplicateline" , "Duplicate Current Line" , {|| ::oEM:duplicateLine() } } )
aadd( aBtns, { "movelineup" , "Move Current Line Up" , {|| ::oEM:moveLine( -1 ) } } )
aadd( aBtns, { "movelinedown" , "Move Current Line Down" , {|| ::oEM:moveLine( 1 ) } } )
aadd( aBtns, { "deleteline" , "Delete Current Line" , {|| ::oEM:deleteLine() } } )
aadd( aBtns, { "duplicateline" , "Duplicate Current Line" , {|| ::oEM:duplicateLine() } } )
aadd( aBtns, {} )
aadd( aBtns, { "togglelinenumber", "Toggle Line Numbers" , ;
{|| ::oIde:lLineNumbersVisible := ! ::lLineNumbersVisible, ::oEM:toggleLineNumbers() } } )
aadd( aBtns, { "togglelinenumber", "Toggle Line Numbers" , {|| ::oEM:toggleLineNumbers() } } )
aadd( aBtns, { "curlinehilight" , "Toggle Current Line Hilight", {|| ::oEM:toggleCurrentLineHighlightMode() } } )
FOR EACH a_ IN aBtns
IF empty( a_ )
::qTBarLines:addSeparator()

View File

@@ -207,6 +207,7 @@ CLASS IdeEdit INHERIT IdeObject
METHOD blockConvert( cMode )
METHOD clearSelection()
METHOD dispStatusInfo()
METHOD toggleCurrentLineHighlightMode()
ENDCLASS
@@ -441,11 +442,12 @@ METHOD IdeEdit:execEvent( nMode, oEdit, p, p1 )
/* Book Marks reach-out buttons */
::relayMarkButtons()
::toggleLineNumbers()
::updateTitleBar()
::toggleLineNumbers()
::toggleCurrentLineHighlightMode()
::dispStatusInfo()
::oDK:setStatusText( SB_PNL_SELECTEDCHARS, len( ::getSelectedText() ) )
EXIT
@@ -1245,6 +1247,12 @@ METHOD IdeEdit:toggleLineSelectionMode()
/*----------------------------------------------------------------------*/
METHOD IdeEdit:toggleCurrentLineHighlightMode()
::qEdit:hbHighlightCurrentLine( ::lCurrentLineHighlightEnabled )
RETURN Self
/*----------------------------------------------------------------------*/
METHOD IdeEdit:redo()
::qEdit:redo()
RETURN Self

View File

@@ -140,6 +140,7 @@ CLASS IdeEditsManager INHERIT IdeObject
METHOD toggleSelectionMode()
METHOD toggleLineNumbers()
METHOD toggleLineSelectionMode()
METHOD toggleCurrentLineHighlightMode()
METHOD getText()
METHOD getWord( lSelect )
@@ -551,6 +552,7 @@ METHOD IdeEditsManager:toggleLineSelectionMode()
METHOD IdeEditsManager:toggleSelectionMode()
LOCAL oEdit
::oIde:isColumnSelectionEnabled := ! ::isColumnSelectionEnabled
IF !empty( oEdit := ::getEditObjectCurrent() )
oEdit:toggleSelectionMode()
ENDIF
@@ -558,6 +560,29 @@ METHOD IdeEditsManager:toggleSelectionMode()
/*----------------------------------------------------------------------*/
METHOD IdeEditsManager:toggleCurrentLineHighlightMode()
LOCAL oEdit
::oIde:lCurrentLineHighlightEnabled := ! ::lCurrentLineHighlightEnabled
IF !empty( oEdit := ::getEditObjectCurrent() )
oEdit:toggleCurrentLineHighlightMode()
ENDIF
RETURN Self
/*----------------------------------------------------------------------*/
METHOD IdeEditsManager:toggleLineNumbers()
LOCAL oEdit
::oIde:lLineNumbersVisible := ! ::lLineNumbersVisible
IF !empty( oEdit := ::getEditObjectCurrent() )
oEdit:toggleLineNumbers()
ENDIF
RETURN Self
/*----------------------------------------------------------------------*/
METHOD IdeEditsManager:duplicateLine()
LOCAL oEdit
IF !empty( oEdit := ::getEditObjectCurrent() )
@@ -657,15 +682,6 @@ METHOD IdeEditsManager:clearSelection()
/*----------------------------------------------------------------------*/
METHOD IdeEditsManager:toggleLineNumbers()
LOCAL oEdit
IF !empty( oEdit := ::getEditObjectCurrent() )
oEdit:toggleLineNumbers()
ENDIF
RETURN Self
/*----------------------------------------------------------------------*/
METHOD IdeEditsManager:gotoFunction()
LOCAL oEdit
IF !empty( oEdit := ::getEditObjectCurrent() )
@@ -1310,6 +1326,7 @@ METHOD IdeEditor:activateTab( mp1, mp2, oXbp )
oEdit:setDocumentProperties()
oEdit:qCoEdit:relayMarkButtons()
oEdit:qCoEdit:toggleLineNumbers()
oEdit:qCoEdit:toggleCurrentLineHighlightMode()
oEdit:qCoEdit:dispStatusInfo()
ENDIF

View File

@@ -235,8 +235,11 @@ METHOD IdeEnvironments:show()
::oUI:signal( "buttonPathEnv" , "clicked()", {|| ::execEnv( 2 ) } )
::oUI:q_editCompilers:setFont( ::oFont:oWidget )
#if 0
::oUI:q_editPathEnv:setFont( ::oFont:oWidget )
::oUI:q_editPathMk2:setFont( ::oFont:oWidget )
#endif
ENDIF
::oUI:q_editPathMk2 :setText( ::aINI[ INI_HBIDE, PathMk2 ] )

View File

@@ -197,6 +197,7 @@ CLASS IdeObject
ACCESS isColumnSelectionEnabled INLINE ::oIde:isColumnSelectionEnabled
ACCESS lLineNumbersVisible INLINE ::oIde:lLineNumbersVisible
ACCESS lStatusBarVisible INLINE ::oIde:lStatusBarVisible
ACCESS lCurrentLineHighlightEnabled INLINE ::oIde:lCurrentLineHighlightEnabled
ACCESS aMarkTBtns INLINE ::oIde:aMarkTBtns

View File

@@ -77,7 +77,7 @@ STATIC s_aLoaded := { { "", .f. } }
/*----------------------------------------------------------------------*/
FUNCTION hbide_loadPlugins()
FUNCTION hbide_loadPlugins( oIde, cVer )
LOCAL cPath := hb_dirBase() + hb_osPathSeparator() + "plugins" + hb_osPathSeparator()
LOCAL dir_, a_, cFile, pHrb, bBlock
@@ -86,11 +86,14 @@ FUNCTION hbide_loadPlugins()
FOR EACH a_ IN dir_
hb_fNameSplit( a_[ 1 ], , @cFile )
pHrb := hb_hrbLoad( HB_HRB_BIND_OVERLOAD, cPath + cFile )
IF ! Empty( pHrb ) .AND. ! Empty( hb_hrbGetFunSym( pHrb, cFile + "_init" ) )
bBlock := &( "{|...| " + cFile + "_init(...) }" )
IF eval( bBlock, "1.0" ) /* Shakehand is OK */
IF eval( bBlock, oIde, cVer )
IF ! Empty( hb_hrbGetFunSym( pHrb, cFile + "_exec" ) )
aadd( s_aPlugins, { lower( cFile ), &( "{|...| " + cFile + "_exec(...) }" ), pHrb } )
ENDIF
ENDIF
ENDIF
@@ -100,7 +103,27 @@ FUNCTION hbide_loadPlugins()
/*----------------------------------------------------------------------*/
FUNCTION hbide_loadAPlugin( cPlugin )
FUNCTION hbide_execPlugin( cPlugin, oIde, ... )
LOCAL n, lLoaded
cPlugin := lower( cPlugin )
IF ( n := ascan( s_aLoaded, {|e_| e_[ 1 ] == cPlugin } ) ) == 0
lLoaded := hbide_loadAPlugin( cPlugin, oIde, "1.0" )
ELSE
lLoaded := s_aLoaded[ n,2 ]
ENDIF
IF lLoaded
IF ( n := ascan( s_aPlugins, {|e_| e_[ 1 ] == cPlugin } ) ) > 0
RETURN eval( s_aPlugins[ n, 2 ], oIde, ... )
ENDIF
ENDIF
RETURN NIL
/*----------------------------------------------------------------------*/
STATIC FUNCTION hbide_loadAPlugin( cPlugin, oIde, cVer )
LOCAL cPath, pHrb, bBlock, lLoaded
cPath := hb_dirBase() + hb_osPathSeparator() + "plugins" + hb_osPathSeparator() + cPlugin + ".hrb"
@@ -111,7 +134,7 @@ FUNCTION hbide_loadAPlugin( cPlugin )
IF ! Empty( pHrb ) .AND. ! Empty( hb_hrbGetFunSym( pHrb, cPlugin + "_init" ) )
bBlock := &( "{|...| " + cPlugin + "_init(...) }" )
IF eval( bBlock, "1.0" )
IF eval( bBlock, oIde, cVer )
IF ! Empty( hb_hrbGetFunSym( pHrb, cPlugin + "_exec" ) )
aadd( s_aPlugins, { cPlugin, &( "{|...| " + cPlugin + "_exec(...) }" ), pHrb } )
@@ -128,22 +151,3 @@ FUNCTION hbide_loadAPlugin( cPlugin )
/*----------------------------------------------------------------------*/
FUNCTION hbide_execPlugin( cPlugin, oAPI, ... )
LOCAL n, lLoaded
cPlugin := lower( cPlugin )
IF ( n := ascan( s_aLoaded, {|e_| e_[ 1 ] == cPlugin } ) ) == 0
lLoaded := hbide_loadAPlugin( cPlugin )
ELSE
lLoaded := s_aLoaded[ n,2 ]
ENDIF
IF lLoaded
IF ( n := ascan( s_aPlugins, {|e_| e_[ 1 ] == cPlugin } ) ) > 0
RETURN eval( s_aPlugins[ n, 2 ], oAPI, ... )
ENDIF
ENDIF
RETURN NIL
/*----------------------------------------------------------------------*/

View File

@@ -737,6 +737,7 @@ METHOD IdeProjManager:buildInterface()
::oUI:q_editSources :setFont( ::oFont:oWidget )
::oUI:q_editHbp :setFont( ::oFont:oWidget )
#if 0
::oUI:q_editPrjTitle :setFont( ::oFont:oWidget )
::oUI:q_editPrjLoctn :setFont( ::oFont:oWidget )
::oUI:q_editWrkFolder :setFont( ::oFont:oWidget )
@@ -745,7 +746,7 @@ METHOD IdeProjManager:buildInterface()
::oUI:q_editBackup :setFont( ::oFont:oWidget )
::oUI:q_editLaunchParams:setFont( ::oFont:oWidget )
::oUI:q_editLaunchExe :setFont( ::oFont:oWidget )
#endif
RETURN Self
/*----------------------------------------------------------------------*/

View File

@@ -203,6 +203,7 @@ CLASS IdeShortcuts INHERIT IdeObject
METHOD gotoFunction()
METHOD clearSelection()
METHOD execPlugin( cPlugin, ... )
METHOD toggleCurrentLineHilight()
ENDCLASS
@@ -1105,7 +1106,6 @@ METHOD IdeShortcuts:toggleLineNumbersDisplay()
RETURN ::oEM:toggleLineNumbers()
/*----------------------------------------------------------------------*/
METHOD IdeShortcuts:toggleSelectionMode()
::isColumnSelectionEnabled := ! ::isColumnSelectionEnabled
RETURN ::oEM:toggleSelectionMode()
/*----------------------------------------------------------------------*/
METHOD IdeShortcuts:toggleStatusBar()
@@ -1114,7 +1114,7 @@ METHOD IdeShortcuts:toggleStatusBar()
ELSE
::oSBar:oWidget:show()
ENDIF
::lStatusBarVisible := ! ::lStatusBarVisible
::oIde:lStatusBarVisible := ! ::lStatusBarVisible
RETURN Self
/*----------------------------------------------------------------------*/
METHOD IdeShortcuts:toggleLineSelectionMode()
@@ -1132,6 +1132,9 @@ METHOD IdeShortcuts:clearSelection()
METHOD IdeShortcuts:execPlugin( cPlugin, ... )
RETURN hbide_execPlugin( cPlugin, ::oIde, ... )
/*----------------------------------------------------------------------*/
METHOD IdeShortcuts:toggleCurrentLineHilight()
RETURN ::oEM:toggleCurrentLineHighlightMode()
/*----------------------------------------------------------------------*/
METHOD IdeShortcuts:loadMethods()
@@ -1316,6 +1319,9 @@ METHOD IdeShortcuts:loadMethods()
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' } )
RETURN Self

View File

@@ -478,6 +478,9 @@ METHOD IdeThemes:setSyntaxHilighting( qEdit, cTheme, lNew )
aAttr := ::getThemeAttribute( "LineNumbersBkColor", cTheme )
qEdit:hbSetLineAreaBkColor( QColor():new( aAttr[ THM_ATR_R ], aAttr[ THM_ATR_G ], aAttr[ THM_ATR_B ] ) )
aAttr := ::getThemeAttribute( "SelectionBackground", cTheme )
qEdit:hbSetSelectionColor( QColor():new( aAttr[ THM_ATR_R ], aAttr[ THM_ATR_G ], aAttr[ THM_ATR_B ] ) )
ENDIF
qHiliter:setDocument( qEdit:document() )
@@ -541,9 +544,6 @@ METHOD IdeThemes:show()
::oUI:q_listThemes:setCurrentRow( 0 )
::oUI:q_listItems:setCurrentRow( 0 )
//::nCurTheme := 1
//::nCurItem := 1
::setTheme()
::setAttributes()
ENDIF
@@ -1036,7 +1036,7 @@ STATIC FUNCTION hbide_loadDefaultThemes()
aadd( aIni, "CommentsAndRemarks = 165, 165, 165, No, No, No, " )
aadd( aIni, "UnrecognizedText = 0, 0, 0, No, No, No, " )
aadd( aIni, "BookMarkLineBackground = 0, 255, 255, No, No, No, " )
aadd( aIni, "SelectionBackground = 255, 128, 255, No, No, No, " )
aadd( aIni, "SelectionBackground = 220, 200, 135, No, No, No, " )
aadd( aIni, "CurrentLineBackground = 255, 215, 155, No, No, No, " )
aadd( aIni, "UnterminatedStrings = 255, 128, 128, No, No, No, " )
aadd( aIni, "LineNumbersBkColor = 255, 215, 155, No, No, No, " )
@@ -1057,7 +1057,7 @@ STATIC FUNCTION hbide_loadDefaultThemes()
aadd( aIni, "CommentsAndRemarks = 165, 165, 165, No, No, No, " )
aadd( aIni, "UnrecognizedText = 0, 0, 0, No, No, No, " )
aadd( aIni, "BookMarkLineBackground = 0, 255, 255, No, No, No, " )
aadd( aIni, "SelectionBackground = 255, 128, 255, No, No, No, " )
aadd( aIni, "SelectionBackground = 160, 200, 255, No, No, No, " )
aadd( aIni, "CurrentLineBackground = 235, 235, 235, No, No, No, " )
aadd( aIni, "UnterminatedStrings = 255, 128, 128, No, No, No, " )
aadd( aIni, "LineNumbersBkColor = 235, 235, 235, No, No, No, " )
@@ -1078,7 +1078,7 @@ STATIC FUNCTION hbide_loadDefaultThemes()
aadd( aIni, "CommentsAndRemarks = 0,128,255 , No, No, No, " )
aadd( aIni, "UnrecognizedText = 0,0,0 , No, No, No, " )
aadd( aIni, "BookMarkLineBackground = 0,255,255 , No, No, No, " )
aadd( aIni, "SelectionBackground = 255,128,255 , No, No, No, " )
aadd( aIni, "SelectionBackground = 255,200,220 , No, No, No, " )
aadd( aIni, "CurrentLineBackground = 220,220,220 , No, No, No, " )
aadd( aIni, "UnterminatedStrings = 255,128,128 , No, No, No, " )
aadd( aIni, "LineNumbersBkColor = 220,220,220 , No, No, No, " )
@@ -1141,7 +1141,7 @@ STATIC FUNCTION hbide_loadDefaultThemes()
aadd( aIni, "CommentsAndRemarks = 128,128,128 , No, No, No, " )
aadd( aIni, "UnrecognizedText = 0,0,0 , No, No, No, " )
aadd( aIni, "BookMarkLineBackground = 0,255,255 , No, No, No, " )
aadd( aIni, "SelectionBackground = 255,0,255 , No, No, No, " )
aadd( aIni, "SelectionBackground = 125,170,150 , No, No, No, " )
aadd( aIni, "CurrentLineBackground = 220,220,110 , No, No, No, " )
aadd( aIni, "UnterminatedStrings = 128,128,0 , No, No, No, " )
aadd( aIni, "LineNumbersBkColor = 220,220,110 , No, No, No, " )

View File

@@ -48,39 +48,50 @@
* If you do not wish that, delete this exception notice.
*
*/
/*----------------------------------------------------------------------*/
FUNCTION savebackup_init( ... )
#include "common.ch"
/*----------------------------------------------------------------------*/
FUNCTION savebackup_init( oIde, cVer )
HB_SYMBOL_UNUSED( oIde )
HB_SYMBOL_UNUSED( cVer )
IF cVer != "1.0"
RETURN .f.
ENDIF
RETURN .t.
/*----------------------------------------------------------------------*/
FUNCTION savebackup_exec( oIde, ... )
LOCAL c
FOR EACH c IN { ... }
IF lower( c ) == "saveas"
IF lower( c ) == "saveas"
savebackup_saveAs( oIde )
ENDIF
NEXT
ENDIF
NEXT
RETURN NIL
/*----------------------------------------------------------------------*/
STATIC FUNCTION savebackup_saveAs( oIde )
LOCAL cFile, oEdit
oEdit := oIde:oEM:getEditorCurrent()
cFile := oEdit:sourceFile + "_bkp_" + strtran( dtoc( date() ), "/", "-" ) + "_" + strtran( time(), ":", "_" )
cFile := hbide_pathToOSPath( cFile )
hb_memowrit( cFile, oIde:oEM:getEditObjectCurrent():qEdit:toPlainText() )
MsgBox( cFile, "Backup Saved" )
MsgBox( cFile, "Backup Saved" )
RETURN NIL
/*----------------------------------------------------------------------*/

View File

@@ -72,6 +72,8 @@
:hbSetSelectionMode( nMode, lOn ) -> NIL
:hbGetSelectionInfo() -> NIL
:hbSetSelectionInfo( xSelectionInfo ) -> NIL
:hbSetSelectionColor( pColor ) -> NIL
:hbSetMatchBraces( lAll ) -> NIL
$DESCRIPTION$

View File

@@ -94,6 +94,7 @@ HBQPlainTextEdit::HBQPlainTextEdit( QWidget * parent ) : QPlainTextEdit( parent
m_currentLineColor.setNamedColor( "#e8e8ff" );
m_lineAreaBkColor.setNamedColor( "#e4e4e4" );
m_horzRulerBkColor.setNamedColor( "whitesmoke" );
m_matchBracesAll = false;
spaces = 3;
spacesTab = "";
@@ -122,6 +123,9 @@ HBQPlainTextEdit::HBQPlainTextEdit( QWidget * parent ) : QPlainTextEdit( parent
horzRuler->setFrameShape( QFrame::Panel );
horzRuler->setFrameShadow( QFrame::Sunken );
QPalette pl( QPlainTextEdit::palette() );
m_selectionColor = pl.color( QPalette::Highlight );
}
/*----------------------------------------------------------------------*/
@@ -214,6 +218,18 @@ bool HBQPlainTextEdit::event( QEvent *event )
/*----------------------------------------------------------------------*/
void HBQPlainTextEdit::hbSetSelectionColor( const QColor & color )
{
m_selectionColor = color;
QPalette pl( QPlainTextEdit::palette() );
pl.setColor( QPalette::Highlight, m_selectionColor );
pl.setColor( QPalette::HighlightedText, QColor( 0,0,0 ) );
setPalette( pl );
}
/*----------------------------------------------------------------------*/
static bool isNavableKey( int k )
{
return ( k == Qt::Key_Right || k == Qt::Key_Left || k == Qt::Key_Up || k == Qt::Key_Down ||
@@ -738,7 +754,8 @@ bool HBQPlainTextEdit::hbKeyPressColumnSelection( QKeyEvent * event )
}
else
{
//emit selectionChanged();
if( selectionState > 0 )
emit selectionChanged();
setCursorWidth( 1 );
selectionState = 0;
}
@@ -934,6 +951,8 @@ void HBQPlainTextEdit::paintEvent( QPaintEvent * event )
int top = ( int ) blockBoundingGeometry( tblock ).translated( contentOffset() ).top();
int bottom = top + height;
this->hbPaintSelection( event );
while( tblock.isValid() && top <= event->rect().bottom() )
{
if( tblock.isVisible() && bottom >= event->rect().top() )
@@ -960,7 +979,6 @@ void HBQPlainTextEdit::paintEvent( QPaintEvent * event )
bottom = top + height;
++blockNumber;
}
this->hbPaintSelection( event );
#if 0 /* A day wasted - I could not find how I can execute paiting from within prg code */
if( block )
@@ -1115,7 +1133,7 @@ void HBQPlainTextEdit::hbPaintSelection( QPaintEvent * event )
QRect r( x, top, ( w == 0 ? 1 : w ), btm );
p.fillRect( r, QBrush( QColor( 175, 255, 175 ) ) );
p.fillRect( r, QBrush( m_selectionColor ) );
}
else if( selectionMode == selectionMode_stream )
{
@@ -1151,7 +1169,7 @@ void HBQPlainTextEdit::hbPaintSelection( QPaintEvent * event )
{
r = QRect( 0, top, width, fontHeight );
}
p.fillRect( r, QBrush( QColor( 175, 255, 175 ) ) );
p.fillRect( r, QBrush( m_selectionColor ) );
top += fontHeight;
}
}
@@ -1159,7 +1177,7 @@ void HBQPlainTextEdit::hbPaintSelection( QPaintEvent * event )
else if( selectionMode == selectionMode_line )
{
QRect r( 0, top, viewport()->width(), btm );
p.fillRect( r, QBrush( QColor( 175, 255, 175 ) ) );
p.fillRect( r, QBrush( m_selectionColor ) );
}
}
}
@@ -1824,10 +1842,6 @@ void HBQPlainTextEdit::hbBraceHighlight()
QColor lineColor = QColor( Qt::yellow ).lighter( 160 );
QTextDocument *doc = document();
#if 0
docLayout = QPlainTextDocumentLayout( doc );
docLayout->format.setBackground( lineColor );
#endif
extraSelections.clear();
setExtraSelections( extraSelections );
@@ -1870,15 +1884,17 @@ void HBQPlainTextEdit::hbBraceHighlight()
closeBrace = ">";
}
QTextCursor cursor1;
QTextCursor cursor2;
QTextCursor matches;
if( brace == openBrace )
{
QTextCursor cursor1 = doc->find( closeBrace, cursor );
QTextCursor cursor2 = doc->find( openBrace, cursor );
cursor1 = doc->find( closeBrace, cursor );
cursor2 = doc->find( openBrace, cursor );
if( cursor2.isNull() )
{
selection.cursor = cursor1;
extraSelections.append( selection );
setExtraSelections( extraSelections );
matches = cursor1;
}
else
{
@@ -1889,22 +1905,18 @@ void HBQPlainTextEdit::hbBraceHighlight()
if( cursor2.isNull() )
break;
}
selection.cursor = cursor1;
extraSelections.append( selection );
setExtraSelections( extraSelections );
matches = cursor1;
}
}
else
{
if( brace == closeBrace )
{
QTextCursor cursor1 = doc->find( openBrace, cursor, QTextDocument::FindBackward );
QTextCursor cursor2 = doc->find( closeBrace, cursor, QTextDocument::FindBackward );
cursor1 = doc->find( openBrace, cursor, QTextDocument::FindBackward );
cursor2 = doc->find( closeBrace, cursor, QTextDocument::FindBackward );
if( cursor2.isNull() )
{
selection.cursor = cursor1;
extraSelections.append( selection );
setExtraSelections( extraSelections );
matches = cursor1;
}
else
{
@@ -1915,12 +1927,21 @@ void HBQPlainTextEdit::hbBraceHighlight()
if( cursor2.isNull() )
break;
}
selection.cursor = cursor1;
extraSelections.append( selection );
setExtraSelections( extraSelections );
matches = cursor1;
}
}
}
if( ! matches.isNull() )
{
if( m_matchBracesAll )
{
selection.cursor = cursor;
extraSelections.append( selection );
}
selection.cursor = cursor1;
extraSelections.append( selection );
setExtraSelections( extraSelections );
}
}
/*----------------------------------------------------------------------*/

View File

@@ -88,8 +88,10 @@ public:
QColor m_currentLineColor;
QColor m_lineAreaBkColor;
QColor m_horzRulerBkColor;
QColor m_selectionColor;
long m_matchingBegin;
long m_matchingEnd;
bool m_matchBracesAll;
void paintEvent( QPaintEvent * event );
void lineNumberAreaPaintEvent( QPaintEvent * event );
@@ -99,20 +101,20 @@ public:
QString styleHightlighter;
void hbSetStyleHightlighter( const QString & style );
QString hbGetStyleHightlighter() { return styleHightlighter; }
QString hbGetStyleHightlighter() { return styleHightlighter; };
void hbShowHighlighter( const QString & style, bool b );
int hbGetIndex( const QTextCursor &crQTextCursor );
int hbGetLine( const QTextCursor &crQTextCursor );
int hbLineNumberAreaWidth();
int hbGetSpaces() { return spaces; }
int hbGetSpaces() { return spaces; };
void hbSetSpaces( int newSpaces );
void hbBookmarks( int block );
void hbNextBookmark( int block );
void hbPrevBookmark( int block );
void hbGotoBookmark( int block );
void hbHighlightCurrentLine( bool b ) { highlightCurLine = b; }
bool hbHighlightCurrentLine() { return highlightCurLine; }
void hbHighlightCurrentLine( bool b ) { highlightCurLine = b; update(); };
bool hbHighlightCurrentLine() { return highlightCurLine; };
void hbSetEventBlock( PHB_ITEM pBlock );
private:
@@ -185,10 +187,13 @@ public slots:
void hbCut( int key );
void hbCopy();
void hbPaste();
void hbSetSelectionMode( int mode, bool on );
void hbGetSelectionInfo();
void hbToStream();
void hbGetSelectionInfo();
void hbSetSelectionMode( int mode, bool on );
void hbSetSelectionInfo( PHB_ITEM selectionInfo );
void hbSetSelectionColor( const QColor & color );
void hbSetMatchBraces( bool all ){ m_matchBracesAll = all; };
private slots:
void hbSlotCursorPositionChanged();

View File

@@ -776,6 +776,34 @@ HB_FUNC( QT_HBQPLAINTEXTEDIT_HBSETSELECTIONINFO )
}
}
/*
* void hbSetSelectionColor( const QColor & color )
*/
HB_FUNC( QT_HBQPLAINTEXTEDIT_HBSETSELECTIONCOLOR )
{
HBQPlainTextEdit * p = hbqt_par_HBQPlainTextEdit( 1 );
if( p )
( p )->hbSetSelectionColor( *hbqt_par_QColor( 2 ) );
else
{
HB_TRACE( HB_TR_DEBUG, ( "............................... F=QT_HBQPLAINTEXTEDIT_HBSETSELECTIONCOLOR FP=( p )->hbSetSelectionColor( *hbqt_par_QColor( 2 ) ); p is NULL" ) );
}
}
/*
* void hbSetMatchBraces( bool all )
*/
HB_FUNC( QT_HBQPLAINTEXTEDIT_HBSETMATCHBRACES )
{
HBQPlainTextEdit * p = hbqt_par_HBQPlainTextEdit( 1 );
if( p )
( p )->hbSetMatchBraces( hb_parl( 2 ) );
else
{
HB_TRACE( HB_TR_DEBUG, ( "............................... F=QT_HBQPLAINTEXTEDIT_HBSETMATCHBRACES FP=( p )->hbSetMatchBraces( hb_parl( 2 ) ); p is NULL" ) );
}
}
/*----------------------------------------------------------------------*/
#endif /* #if QT_VERSION >= 0x040500 */

View File

@@ -111,6 +111,8 @@ CREATE CLASS HBQPlainTextEdit INHERIT HbQtObjectHandler, QPlainTextEdit
METHOD hbSetSelectionMode( nMode, lOn )
METHOD hbGetSelectionInfo()
METHOD hbSetSelectionInfo( xSelectionInfo )
METHOD hbSetSelectionColor( pColor )
METHOD hbSetMatchBraces( lAll )
ENDCLASS
@@ -299,3 +301,11 @@ METHOD HBQPlainTextEdit:hbGetSelectionInfo()
METHOD HBQPlainTextEdit:hbSetSelectionInfo( xSelectionInfo )
RETURN Qt_HBQPlainTextEdit_hbSetSelectionInfo( ::pPtr, xSelectionInfo )
METHOD HBQPlainTextEdit:hbSetSelectionColor( pColor )
RETURN Qt_HBQPlainTextEdit_hbSetSelectionColor( ::pPtr, hbqt_ptr( pColor ) )
METHOD HBQPlainTextEdit:hbSetMatchBraces( lAll )
RETURN Qt_HBQPlainTextEdit_hbSetMatchBraces( ::pPtr, lAll )

View File

@@ -142,6 +142,9 @@ HB_FUNC( QT_HBQPLAINTEXTEDIT )
void hbSetSelectionMode( int mode, bool on )
void hbGetSelectionInfo()
void hbSetSelectionInfo( PHB_ITEM selectionInfo )
void hbSetSelectionColor( const QColor & color )
void hbSetMatchBraces( bool all )
</SLOTS>
<SIGNALS>