uo_mle_demo.sru 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. $PBExportHeader$uo_mle_demo.sru
  2. forward
  3. global type uo_mle_demo from multilineedit
  4. end type
  5. end forward
  6. global type uo_mle_demo from multilineedit
  7. integer width = 1486
  8. integer height = 540
  9. event keydown pbm_keydown
  10. event keyup pbm_keyup
  11. event ue_textchanged ( )
  12. event char pbm_char
  13. event ue_topmost ( string arg_in, ref string arg_out )
  14. end type
  15. global uo_mle_demo uo_mle_demo
  16. type variables
  17. private:
  18. string _oldtext
  19. public:
  20. string Separater[] = {";", "~r~n"}
  21. end variables
  22. event keyup;if this._oldtext <> this.text then
  23. this.trigger event ue_textChanged()
  24. end if
  25. this._oldtext = this.text
  26. end event
  27. event ue_textchanged();string ls_org, ls_parm, ls_des
  28. long ll_start, ll_end, ll_pos
  29. long ll_selStart, ll_selLen, ll_tmp
  30. string ls_separater
  31. long i
  32. ll_start = 1
  33. do while (true)
  34. ll_pos = 0
  35. for i = 1 to upperbound(this.separater)
  36. ll_tmp = pos(this.text, this.separater[i], ll_start)
  37. if ll_tmp = 0 then continue
  38. if ll_pos = 0 or ll_tmp < ll_pos then
  39. ll_pos = ll_tmp
  40. ls_separater = this.separater[i]
  41. end if
  42. next
  43. if ll_pos = 0 then
  44. ll_end = len(this.text)
  45. exit
  46. end if
  47. if ll_pos >= this.Position( ) then
  48. ll_end = ll_pos - 1
  49. exit
  50. else
  51. ll_start = ll_pos + len(ls_separater)
  52. end if
  53. loop
  54. ls_parm = mid(this.text, ll_start, ll_end - ll_start + 1)
  55. if trim(ls_parm) = '' then
  56. return
  57. end if
  58. this.trigger event ue_topmost(ls_parm, ls_des)
  59. ll_selStart = ll_start + len(ls_parm)
  60. ll_selLen = len(ls_des) - len(ls_parm)
  61. this.text = mid(this.text, 1, ll_start - 1) + ls_des + mid(this.text, ll_end + 1, len(this.text) - ll_end)
  62. this.selecttext(ll_selStart, ll_selLen)
  63. end event
  64. event char;if key = '~r' and this.selectedlength( ) > 0 then
  65. this.selecttext(this.selectedstart() + this.selectedlength(), 0)
  66. return 1
  67. end if
  68. if this.selectedlength( ) > 0 then
  69. this.clear()
  70. end if
  71. this._oldtext = this.text
  72. end event
  73. event ue_topmost(string arg_in, ref string arg_out);arg_out = arg_in
  74. end event
  75. on uo_mle_demo.create
  76. end on
  77. on uo_mle_demo.destroy
  78. end on
  79. event constructor;this._oldtext = this.text
  80. end event