edit.tcl 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. ###########################################################
  2. # Name: edit.tcl
  3. # Author: Daniele Bonini (posta@elettronica.lol)
  4. # Date: 27/11/2023
  5. # Desc: Edit Menu namespace of RadXIDE.
  6. #
  7. # Edit Menu namespace scaffolding and most of the code
  8. # here presented and distributed contains excerpts
  9. # from [alited](https://github.com/aplsimple/alited
  10. # by Alex Plotnikov and contributors to the project.
  11. # The original code of these excerpts could be
  12. # borrowed from other sources which the author
  13. # and the contributors to this RadXIDE have no
  14. # knowledge about.
  15. #
  16. # License: MIT. Copyrights 5 Mode (Last implementation and adaptations.)
  17. # Copyright (c) 2021-2023 Alex Plotnikov https://aplsimple.github.io (original scaffolding and excerpts.)
  18. #
  19. ###########################################################
  20. namespace eval edit {
  21. # ________________________ find _________________________ #
  22. proc find {} {
  23. # Open the Find window to start a text search
  24. namespace upvar ::radxide dan dan project project
  25. set t $dan(TEXT)
  26. set args {}
  27. if {$project(CUR_FILE_PATH) ne {}} {
  28. #tk_textCopy $t
  29. #catch {clipboard get} clipcontent
  30. #set sel $clipcontent
  31. set sel [::radxide::win::InitFindInText 0 $t]
  32. #tk_messageBox -title $dan(TITLE) -icon info -message $sel
  33. set args "-buttons {butSearch SEARCH ::radxide::win::findTextOK butCANCEL CANCEL ::radxide::win::findTextCancel}"
  34. catch {lassign [::radxide::win::input "Find" {} "Find text" [list \
  35. ent "{} {} {-w 64}" "{$sel}"] \
  36. -head "Search for:" {*}$args] res}
  37. }
  38. }
  39. # ________________________ GotoLine _________________________ #
  40. proc GotoLine {} {
  41. # Open the Go To Line window
  42. namespace upvar ::radxide dan dan project project
  43. set t $dan(TEXT)
  44. set args {}
  45. set ln 1
  46. if {$project(CUR_FILE_PATH) ne {}} {
  47. #tk_messageBox -title $dan(TITLE) -icon info -message "Go To Line"
  48. set args "-buttons {butGo GO ::radxide::win::GotoLineOK butCANCEL CANCEL ::radxide::win::GotoLineCancel}"
  49. catch {lassign [::radxide::win::input "GotoLine" {} "Go to Line" [list \
  50. ent "{} {} {-w 28}" "{$ln}"] \
  51. -head "Go to line:" {*}$args] res}
  52. }
  53. }
  54. # ________________________ makeCopy _________________________ #
  55. proc makeCopy {} {
  56. # Copy from the editor to the clipboard
  57. #clipboard clear
  58. #clipboard append $txt
  59. namespace upvar ::radxide dan dan
  60. set t $dan(TEXT)
  61. tk_textCopy $t
  62. }
  63. #_________________________ makeCut ________________________ #
  64. proc makeCut {} {
  65. # Cut from the editor to the clipboard
  66. #set canvas %W
  67. #eval [clipboard get -type TkCanvasItem]
  68. namespace upvar ::radxide dan dan
  69. set t $dan(TEXT)
  70. tk_textCut $t
  71. }
  72. #_________________________ makePaste ________________________ #
  73. proc makePaste {} {
  74. # Paste from the clipboard to the editor
  75. #set canvas %W
  76. #eval [clipboard get -type TkCanvasItem]
  77. namespace upvar ::radxide dan dan
  78. set t $dan(TEXT)
  79. tk_textPaste $t
  80. }
  81. #_________________________ setup ________________________ #
  82. proc setup {} {
  83. # Open the Options window
  84. namespace upvar ::radxide dan dan
  85. tk_messageBox -title $dan(TITLE) -icon info -message "Setup!"
  86. }
  87. #_______________________
  88. }
  89. # _________________________________ EOF _________________________________ #