Update Ring Notepad - rnotefind.ring - Find Previous - Feature added by Gal Zsolt in Ring Group
@@ -51,6 +51,11 @@ class RNoteFind
setText("Find/Find Next")
setclickEvent(Method(:FindValue))
}
+ oBtnFindPrev = new qPushButton(this.oSearch)
+ {
+ setText("Find/Find Prev")
+ setclickEvent(Method(:FindPrevValue))
+ }
oBtnReplace = new qPushButton(this.oSearch)
{
setText("Replace")
@@ -69,6 +74,7 @@ class RNoteFind
oLayout4 = new qHBoxLayout()
{
addWidget(oBtnFind)
+ addWidget(oBtnFindPrev)
addWidget(oBtnReplace)
addWidget(oBtnReplaceAll)
addWidget(oBtnClose)
@@ -184,3 +190,46 @@ class RNoteFind
}
return false
ok
+
+ func FindPrevValue
+ oCursor = textedit1.textcursor()
+ nPosStart = oCursor.Position()
+ cValue = oSearchValue.text()
+ cStr = textedit1.toplaintext()
+ cStr = substr(cStr,1,nPosStart-1)
+ if oSearchCase.checkState() = Qt_Unchecked
+ cStr = lower(cStr) cValue = lower(cValue)
+ ok
+ cnt = count(cStr,cValue)
+ postemp = 1
+ nPos = 0
+ for n = 1 to cnt
+ nPos = substring(cStr,cValue,postemp+1)
+ postemp = nPos
+ next
+ if nPos > 0
+ nPos = nPos - 1
+ oCursor = textedit1.textcursor()
+ oCursor.setposition(nPos,0)
+ textedit1.settextcursor(oCursor)
+ oCursor = textedit1.textcursor()
+ oCursor.setposition(nPos+len(cValue),1)
+ textedit1.settextcursor(oCursor)
+ return true
+ else
+ new qMessagebox(oSearch)
+ {
+ SetWindowTitle("Search")
+ SetText("Cannot find :" + cValue)
+ show()
+ }
+ return false
+ ok
+
+ func count(cString,dString)
+ sum = 0
+ while substr(cString,dString) > 0
+ sum = sum + 1
+ cString = substr(cString,substr(cString,dString)+len(string(sum)))
+ end
+ return sum
