Update applications/rnote/rnoteeditmenu.ring - Better Code.
@@ -108,7 +108,7 @@ class RNoteEditMenu
ok
textedit1.setPlainText(cNewStr)
- func capitalize
+ func Capitalize
oCursor = textedit1.textCursor()
nStart = oCursor.SelectionStart() + 1
nEnd = oCursor.SelectionEnd() + 1
@@ -134,46 +134,50 @@ class RNoteEditMenu
ok
textedit1.setPlainText(cNewStr)
- func commentlines
+ func CommentLines
+
oCursor = textedit1.textCursor()
- nStart = oCursor.SelectionStart()
- nEnd = oCursor.SelectionEnd()
+ nStart = oCursor.SelectionStart() + 1
+ nEnd = oCursor.SelectionEnd() + 1
cStr = textedit1.toPlainText()
- cStr1 = left(cStr, nStart)
- cStr2 = substr(cStr, nStart+1,nEnd-nStart+1)
- cStr3 = substr(cStr,nEnd+1)
- cStrL = str2list(cStr2)
- cList = []
- for x in cStrL
- if x[1] = '/' and x[2] = '/'
- x = substr(x, 4)
- else
- x = '/'+'/' + ' ' + x
+ cNewStr = ""
+ if nStart > 1
+ cNewStr += left(cStr,nStart-1)
+ ok
+
+ cNewStr2 = substr(cStr,nStart,nEnd-nStart)
+ aList = str2list(cNewStr2)
+ for cItem in aList
+ if len(cItem) > 3
+ if cItem[1] = '/' and cItem[2] = '/'
+ cItem = substr(cItem, 4)
+ loop
+ ok
ok
- if x != '' add(cList, x) ok
+ cItem = "// " + cItem
next
- cStr2 = list2str(cList)
- cStr = cStr1 + cStr2 + cStr3
- textedit1.setPlainText(cStr)
- oCursor.setposition(nEnd+1,0)
- textedit1.settextcursor(oCursor)
+ cNewStr += list2str(aList)
+
+ if nEnd < len(cStr)
+ cNewStr += substr(cStr,nEnd)
+ ok
+ textedit1.setPlainText(cNewStr)
+
+ func CommentBlocklines
- func commentBlocklines
oCursor = textedit1.textCursor()
- nStart = oCursor.SelectionStart()
- nEnd = oCursor.SelectionEnd()
+ nStart = oCursor.SelectionStart() + 1
+ nEnd = oCursor.SelectionEnd() + 1
cStr = textedit1.toPlainText()
- cStr1 = left(cStr, nStart)
- cStr2 = substr(cStr, nStart, nEnd-nStart+1)
- cStr3 = substr(cStr,nEnd+1)
- cStrL = str2list(cStr2)
- cList = []
- for x in cStrL
- x = " "+" "+ x
- if x != '' add(cList, x) ok
- next
- cStr2 = list2str(cList)
- cStr = cStr1 + "/*" + cStr2 + " */" + cStr3
- textedit1.setPlainText(cStr)
- oCursor.setposition(nEnd+1,0)
- textedit1.settextcursor(oCursor)
+ cNewStr = ""
+ if nStart > 1
+ cNewStr += left(cStr,nStart-1)
+ ok
+
+ cNewStr2 = substr(cStr,nStart,nEnd-nStart)
+ cNewStr += "/*" + nl + cNewStr2 + nl + "*/"
+
+ if nEnd < len(cStr)
+ cNewStr += substr(cStr,nEnd)
+ ok
+ textedit1.setPlainText(cNewStr)
