2000-10-23 18:15 GMT+2 Maurilio Longo <maurilio.longo@libero.it>
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
2000-10-23 18:15 GMT+2 Maurilio Longo <maurilio.longo@libero.it>
|
||||
* source/rtl/teditor.prg
|
||||
+ added KeyboardHook() and IdleHook() methods.
|
||||
* contrib/mysql/tsqlbrw.prg
|
||||
+ little changes.
|
||||
|
||||
2000-10-22 09:05 UTC+0800 Ron Pinkas <ron@profit-master.com>
|
||||
* source/compiler/simplex.c
|
||||
! Corrrected bug reported by Luiz regarding menuto.prg
|
||||
|
||||
@@ -121,11 +121,17 @@ CLASS TBrowseSQL from TBrowse
|
||||
DATA oQuery // Query / table object which we are browsing
|
||||
|
||||
METHOD New(nTop, nLeft, nBottom, nRight, oServer, oQuery, cTable)
|
||||
|
||||
METHOD EditField() // Editing of hilighted field, after editing does an update of
|
||||
// corresponding row inside table
|
||||
METHOD BrowseTable(nKey, lCanEdit) // Handles standard moving inside table and if lCanEdit == .T.
|
||||
// allows editing of field. It is the stock ApplyKey() moved inside a table
|
||||
// if lCanEdit K_DEL deletes current row
|
||||
|
||||
METHOD BrowseTable(lCanEdit, aExitKeys) // Handles standard moving inside table and if lCanEdit == .T.
|
||||
// allows editing of field. It is the stock ApplyKey() moved inside a table
|
||||
// if lCanEdit K_DEL deletes current row
|
||||
// When a key is pressed which is present inside aExitKeys it leaves editing loop
|
||||
|
||||
METHOD KeyboardHook(nKey) // Where do all unknown keys go?
|
||||
|
||||
ENDCLASS
|
||||
|
||||
|
||||
@@ -314,75 +320,97 @@ METHOD EditField() CLASS TBrowseSQL
|
||||
RETURN Self
|
||||
|
||||
|
||||
METHOD BrowseTable(nKey, lCanEdit) CLASS TBrowseSQL
|
||||
METHOD BrowseTable(lCanEdit, aExitKeys) CLASS TBrowseSQL
|
||||
|
||||
local nKey
|
||||
local lKeepGoing := .T.
|
||||
|
||||
default nKey to nil
|
||||
default lCanEdit to .F.
|
||||
default aExitKeys to {K_ESC}
|
||||
|
||||
|
||||
do case
|
||||
case nKey == K_DOWN
|
||||
::down()
|
||||
while lKeepGoing
|
||||
|
||||
case nKey == K_PGDN
|
||||
::pageDown()
|
||||
|
||||
case nKey == K_CTRL_PGDN
|
||||
::goBottom()
|
||||
|
||||
case nKey == K_UP
|
||||
::up()
|
||||
|
||||
case nKey == K_PGUP
|
||||
::pageUp()
|
||||
|
||||
case nKey == K_CTRL_PGUP
|
||||
::goTop()
|
||||
|
||||
case nKey == K_RIGHT
|
||||
::right()
|
||||
|
||||
case nKey == K_LEFT
|
||||
::left()
|
||||
|
||||
case nKey == K_HOME
|
||||
::home()
|
||||
|
||||
case nKey == K_END
|
||||
::end()
|
||||
|
||||
case nKey == K_CTRL_LEFT
|
||||
::panLeft()
|
||||
|
||||
case nKey == K_CTRL_RIGHT
|
||||
::panRight()
|
||||
|
||||
case nKey == K_CTRL_HOME
|
||||
::panHome()
|
||||
|
||||
case nKey == K_CTRL_END
|
||||
::panEnd()
|
||||
|
||||
case nKey == K_RETURN
|
||||
if lCanEdit
|
||||
::EditField()
|
||||
if !::Stable
|
||||
::ForceStable()
|
||||
endif
|
||||
|
||||
/*case nKey == K_DEL
|
||||
if lCanEdit
|
||||
if ! ::oQuery:Delete(::oCurRow)
|
||||
Alert("not deleted " + ::oQuery:Error())
|
||||
endif
|
||||
if !::oQuery:Refresh()
|
||||
Alert(::oQuery:Error())
|
||||
endif
|
||||
nKey := Inkey(0)
|
||||
|
||||
::inValidate()
|
||||
::refreshAll():forceStable()
|
||||
endif*/
|
||||
if AScan(aExitKeys, nKey) > 0
|
||||
lKeepGoing := .F.
|
||||
LOOP
|
||||
endif
|
||||
|
||||
otherwise
|
||||
endcase
|
||||
do case
|
||||
case nKey == K_DOWN
|
||||
::down()
|
||||
|
||||
case nKey == K_PGDN
|
||||
::pageDown()
|
||||
|
||||
case nKey == K_CTRL_PGDN
|
||||
::goBottom()
|
||||
|
||||
case nKey == K_UP
|
||||
::up()
|
||||
|
||||
case nKey == K_PGUP
|
||||
::pageUp()
|
||||
|
||||
case nKey == K_CTRL_PGUP
|
||||
::goTop()
|
||||
|
||||
case nKey == K_RIGHT
|
||||
::right()
|
||||
|
||||
case nKey == K_LEFT
|
||||
::left()
|
||||
|
||||
case nKey == K_HOME
|
||||
::home()
|
||||
|
||||
case nKey == K_END
|
||||
::end()
|
||||
|
||||
case nKey == K_CTRL_LEFT
|
||||
::panLeft()
|
||||
|
||||
case nKey == K_CTRL_RIGHT
|
||||
::panRight()
|
||||
|
||||
case nKey == K_CTRL_HOME
|
||||
::panHome()
|
||||
|
||||
case nKey == K_CTRL_END
|
||||
::panEnd()
|
||||
|
||||
case nKey == K_RETURN .AND. lCanEdit
|
||||
::EditField()
|
||||
|
||||
/*case nKey == K_DEL
|
||||
if lCanEdit
|
||||
if ! ::oQuery:Delete(::oCurRow)
|
||||
Alert("not deleted " + ::oQuery:Error())
|
||||
endif
|
||||
if !::oQuery:Refresh()
|
||||
Alert(::oQuery:Error())
|
||||
endif
|
||||
|
||||
::inValidate()
|
||||
::refreshAll():forceStable()
|
||||
endif*/
|
||||
|
||||
otherwise
|
||||
::KeyboardHook(nKey)
|
||||
endcase
|
||||
enddo
|
||||
|
||||
return Self
|
||||
|
||||
|
||||
// Empty method to be subclassed
|
||||
METHOD KeyboardHook(nKey) CLASS TBrowseSQL
|
||||
|
||||
return Self
|
||||
|
||||
@@ -103,6 +103,9 @@ CLASS TEditor
|
||||
METHOD InsertState(lInsState) // Changes lInsert value and insertion / overstrike mode of editor
|
||||
METHOD Edit(nPassedKey) // Handles input (can receive a key in which case handles only this key and then exits)
|
||||
|
||||
METHOD KeyboardHook(nKey) // Gets called every time there is a key not handled directly by TEditor
|
||||
METHOD IdleHook() // Gets called every time there are no more keys to hanlde just before TEditor blocks itself waiting for a char
|
||||
|
||||
METHOD Resize(nTop, nLeft, nBottom, nRight) // Redefines editor window size and refreshes it
|
||||
METHOD SetColor(cColorString) // Sets/retrieves color used for screen writes
|
||||
METHOD Hilite() // Start Hilighting swapping first two color definitions inside cColorSpec
|
||||
@@ -784,8 +787,11 @@ METHOD Edit(nPassedKey) CLASS TEditor
|
||||
|
||||
while lKeepGoing
|
||||
|
||||
// If I've been called with a key already preset, evaluate this key and then exit
|
||||
// If I haven't been called with a key already preset, evaluate this key and then exit
|
||||
if nPassedKey == NIL
|
||||
if NextKey() == 0
|
||||
::IdleHook()
|
||||
endif
|
||||
nKey := InKey(0)
|
||||
else
|
||||
lKeepGoing := .F.
|
||||
@@ -793,7 +799,7 @@ METHOD Edit(nPassedKey) CLASS TEditor
|
||||
endif
|
||||
|
||||
do case
|
||||
case nKey >= 32 .AND. nKey <= 255
|
||||
case nKey >= K_SPACE .AND. nKey < 256
|
||||
// If I'm past EOL I need to add as much spaces as I need to reach ::nCol
|
||||
if ::nCol > ::LineLen(::nRow)
|
||||
::aText[::nRow]:cText += Space(::nCol - ::LineLen(::nRow))
|
||||
@@ -885,7 +891,9 @@ METHOD Edit(nPassedKey) CLASS TEditor
|
||||
lKeepGoing := .F.
|
||||
|
||||
otherwise
|
||||
/* TODO: Here we should call an user defined function (to match memoedit() behaviour) */
|
||||
/* NOTE: if you call ::Edit() with a key that is passed to ::KeyboardHook() and then
|
||||
::KeyboardHook() calls ::Edit() with the same key you end up with an endless loop */
|
||||
::KeyboardHook(nKey)
|
||||
endcase
|
||||
enddo
|
||||
endif
|
||||
@@ -893,6 +901,19 @@ METHOD Edit(nPassedKey) CLASS TEditor
|
||||
return Self
|
||||
|
||||
|
||||
// This in an empty method which can be used by classes subclassing TEditor to be able
|
||||
// to handle particular keys.
|
||||
METHOD KeyboardHook(nKey) CLASS TEditor
|
||||
|
||||
return Self
|
||||
|
||||
|
||||
// There are no more keys to handle. Can I do something for you?
|
||||
METHOD IdleHook() CLASS TEditor
|
||||
|
||||
return Self
|
||||
|
||||
|
||||
METHOD SetColor(cColorString) CLASS TEditor
|
||||
|
||||
local cOldColor := ::cColorSpec
|
||||
|
||||
Reference in New Issue
Block a user