edit.tcl 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 {butSearch SEARCH ::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 {win} {
  56. # Copy from the textPane to the clipboard
  57. #clipboard clear
  58. #clipboard append $txt
  59. tk_textCopy $win
  60. }
  61. #_________________________ makeCut ________________________ #
  62. proc makeCut {win} {
  63. # Cut from the textPane to the clipboard
  64. #set canvas %W
  65. #eval [clipboard get -type TkCanvasItem]
  66. tk_textCut $win
  67. }
  68. #_________________________ makePaste ________________________ #
  69. proc makePaste {win} {
  70. # Paste from the clipboard to the textPane
  71. #set canvas %W
  72. #eval [clipboard get -type TkCanvasItem]
  73. tk_textPaste $win
  74. }
  75. #_________________________ setup ________________________ #
  76. proc setup {} {
  77. # Open the Options window
  78. namespace upvar ::radxide dan dan
  79. tk_messageBox -title $dan(TITLE) -icon info -message "Setup!"
  80. }
  81. #_______________________
  82. }
  83. # _________________________________ EOF _________________________________ #