menu.tcl 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. ###########################################################
  2. # Name: menu.tcl
  3. # Author: Daniele Bonini (posta@elettronica.lol)
  4. # Date: 27/11/2023
  5. # Desc: Menu namespace of RadXIDE.
  6. #
  7. # Menu namespace 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 menu {
  21. # ________________________ MenuScaf _________________________ #
  22. proc menuScaf {} {
  23. namespace upvar ::radxide dan dan menu menu
  24. global version
  25. global os
  26. # menu
  27. set menu(ROOT) [set m [menu .mb]]
  28. $m add cascade -label File -menu $m.file
  29. set m1 [menu $m.file -tearoff 0]
  30. set menu(FILE) $m1
  31. $m1 add command -label "New project" -command { ::radxide::menu::file::newProject } -accelerator Ctrl+N
  32. $m1 add command -label "Open project" -command { ::radxide::menu::file::openProject } -accelerator Ctrl+O
  33. $m1 add command -label "Add file" -command { ::radxide::menu::file::addFile } -accelerator Ctrl+Shift+N -state disabled
  34. $m1 add separator
  35. $m1 add command -label "Save as.." -command { ::radxide::menu::file::saveFileAs } -accelerator Ctrl+Shift+S -state disabled
  36. $m1 add command -label "Save" -command { ::radxide::menu::file::saveFile } -accelerator Ctrl-S -state disabled
  37. $m1 add separator
  38. $m1 add command -label "Close" -command { ::radxide::menu::file::closeFile } -accelerator Ctrl+Shift+X -state disabled
  39. $m1 add command -label "Close project" -command { ::radxide::menu::file::closeProject } -accelerator Ctrl+Alt+X -state disabled
  40. $m1 add separator
  41. $m1 add command -label Exit -command { ::radxide::menu::file::quit } -accelerator Ctrl+Q
  42. $m add cascade -label Edit -menu $m.edit
  43. set m2 [menu $m.edit -tearoff 0]
  44. set menu(EDIT) $m2
  45. $m add cascade -label Help -menu $m.help
  46. $m2 add command -label Undo -command { ::radxide::menu::edit::makeUndo "menu" } -accelerator Ctrl+Z -state disabled
  47. $m2 add command -label Redo -command { ::radxide::menu::edit::makeRedo "menu" } -accelerator Ctrl+Shift+Z -state disabled
  48. $m2 add separator
  49. $m2 add command -label Copy -command { ::radxide::menu::edit::makeCopy "menu"} -accelerator Ctrl+C -state disabled
  50. $m2 add command -label Paste -command { ::radxide::menu::edit::makePaste "menu"} -accelerator Ctrl+P -state disabled
  51. $m2 add command -label Cut -command { ::radxide::menu::edit::makeCut "menu"} -accelerator Ctrl+X -state disabled
  52. $m2 add separator
  53. $m2 add command -label Indent -command { ::radxide::menu::edit::Indent "menu" } -accelerator Tab -state disabled
  54. $m2 add command -label UnIndent -command { ::radxide::menu::edit::UnIndent "menu"} -accelerator Shift+Tab -state disabled
  55. $m2 add separator
  56. $m2 add command -label Find -command { ::radxide::menu::edit::find } -accelerator Ctrl+F -state disabled
  57. $m2 add command -label "Go to Line" -command { ::radxide::menu::edit::GotoLine } -accelerator Ctrl+G -state disabled
  58. $m2 add separator
  59. $m2 add command -label Options -command { ::radxide::menu::edit::setup }
  60. set m3 [menu $m.help -tearoff 0]
  61. $m3 add command -label About -command { tk_messageBox -title $dan(TITLE) -icon info -message "\n\nRADXIDE ver $version\n\n\nMIT Licence.\n\n\nCopyright (c) 5 Mode\n\nThis software is provided AS-IS.\n\nAuthors:\n2023-2024 RADXIDE, Daniele Bonini\n2021-2023 Alited, Alex Plotnikov\n2018-2021 Tcler's Wiki\n\nhttps://5mode.com\n\n___________________________________\n\nWork dir:\n$dan(WORKDIR)\n\nOS: $os\n\n\n"}
  62. return $m
  63. }
  64. # ________________________ defMUShortcuts _________________________ #
  65. proc defWinShortcuts {ctrl canvas} {
  66. namespace upvar ::radxide dan dan
  67. bind $ctrl "<Control-n>" { ::radxide::menu::file::newProject }
  68. bind $ctrl "<Control-o>" { ::radxide::menu::file::openProject }
  69. bind $ctrl "<Control-s>" { ::radxide::menu::file::saveFile }
  70. bind $ctrl "<Control-Alt-x>" { ::radxide::menu::file::closeProject }
  71. bind $ctrl "<Control-q>" { ::radxide::menu::file::quit }
  72. #bind $ctrl "<Tab>" { ::radxide::menu::edit::Indent }
  73. #bind $ctrl "<ISO_Left_Tab>" { ::radxide::menu::edit::UnIndent }
  74. #bind $ctrl "<ISO_Right_Tab>" { ::radxide::menu::edit::UnIndent }
  75. bind $ctrl "<Control-z>" "::radxide::menu::edit::makeUndo"
  76. bind $ctrl "<Control-Shift-z>" "::radxide::menu::edit::makeRedo"
  77. bind $ctrl "<Control-c>" "::radxide::menu::edit::makeCopy"
  78. bind $ctrl "<Control-v>" "::radxide::menu::edit::makePaste"
  79. bind $ctrl "<Control-x>" "::radxide::menu::edit::makeCut"
  80. bind $ctrl "<Control-f>" "::radxide::menu::edit::find"
  81. bind $ctrl "<Control-g>" "::radxide::menu::edit::GotoLine"
  82. bind $ctrl "<Return>" "::radxide::menu::edit::makeNewLine"
  83. #bind $ctrl "<Tab>" "::radxide::win::insertTab"
  84. }
  85. #_______________________
  86. source [file join $::radxide::SRCDIR file.tcl]
  87. source [file join $::radxide::SRCDIR edit.tcl]
  88. }
  89. # _________________________________ EOF _________________________________ #