menu.tcl 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. set aboutTEXT ""
  27. #set aboutTEXT "MIT Licence.\n\n\n"
  28. #set aboutTEXT "${aboutTEXT}Copyrights 5 Mode\n\n"
  29. #set aboutTEXT "${aboutTEXT}http://5mode.com\n\n\n"
  30. #set aboutTEXT "${aboutTEXT}Most of code here presented and distributed contain excerpts"
  31. #set aboutTEXT "${aboutTEXT}from Alited (https://github.com/aplsimple/alited"
  32. #set aboutTEXT "${aboutTEXT}by Alex Plotnikov and contributors to the project."
  33. #set aboutTEXT "${aboutTEXT}The original code of these excerpts could be"
  34. #set aboutTEXT "${aboutTEXT}borrowed from other sources which the author"
  35. #set aboutTEXT "${aboutTEXT}and the contributors to this RadXIDE have no"
  36. #set aboutTEXT "${aboutTEXT}knowledge about.\n\n\n"
  37. #set aboutTEXT "${aboutTEXT}For other rights and copyright see each file header."
  38. # menu
  39. set menu(ROOT) [set m [menu .mb]]
  40. $m add cascade -label File -menu $m.file
  41. set m1 [menu $m.file -tearoff 0]
  42. set menu(FILE) $m1
  43. $m1 add command -label "New project" -command { ::radxide::menu::file::newProject } -accelerator Ctrl+N
  44. $m1 add command -label "Open project" -command { ::radxide::menu::file::openProject } -accelerator Ctrl+O
  45. $m1 add command -label "Add file" -command { ::radxide::menu::file::addFile } -accelerator Ctrl+Shift+N -state disabled
  46. $m1 add separator
  47. $m1 add command -label "Save as.." -command { ::radxide::menu::file::saveFileAs } -accelerator Ctrl+Shift+S -state disabled
  48. $m1 add command -label "Save" -command { ::radxide::menu::file::saveFile } -accelerator Ctrl-S -state disabled
  49. $m1 add separator
  50. $m1 add command -label "Close" -command { ::radxide::menu::file::closeFile } -accelerator Ctrl+Shift+X -state disabled
  51. $m1 add command -label "Close project" -command { ::radxide::menu::file::closeProject } -accelerator Ctrl+Alt+X -state disabled
  52. $m1 add separator
  53. $m1 add command -label Exit -command { ::radxide::menu::file::quit } -accelerator Ctrl+Q
  54. $m add cascade -label Edit -menu $m.edit
  55. set m2 [menu $m.edit -tearoff 0]
  56. set menu(EDIT) $m2
  57. $m add cascade -label Help -menu $m.help
  58. $m2 add command -label Copy -command { ::radxide::menu::edit::makeCopy } -accelerator Ctrl+C -state disabled
  59. $m2 add command -label Paste -command { ::radxide::menu::edit::makePaste } -accelerator Ctrl+P -state disabled
  60. $m2 add command -label Cut -command { ::radxide::menu::edit::makeCut } -accelerator Ctrl+X -state disabled
  61. $m2 add separator
  62. $m2 add command -label Find -command { ::radxide::menu::edit::find } -accelerator Ctrl+F -state disabled
  63. $m2 add command -label "Go to Line" -command { ::radxide::menu::edit::GotoLine } -accelerator Ctrl+G -state disabled
  64. $m2 add separator
  65. $m2 add command -label Options -command { ::radxide::menu::edit::setup }
  66. set m3 [menu $m.help -tearoff 0]
  67. $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"}
  68. return $m
  69. }
  70. # ________________________ defMUShortcuts _________________________ #
  71. proc defWinShortcuts {ctrl canvas} {
  72. namespace upvar ::radxide dan dan
  73. bind $ctrl "<Control-n>" { ::radxide::menu::file::newProject }
  74. bind $ctrl "<Control-o>" { ::radxide::menu::file::openProject }
  75. bind $ctrl "<Control-s>" { ::radxide::menu::file::saveFile }
  76. bind $ctrl "<Control-Alt-x>" { ::radxide::menu::file::closeProject }
  77. bind $ctrl "<Control-q>" { ::radxide::menu::file::quit }
  78. bind $ctrl "<Control-c>" "::radxide::menu::edit::makeCopy"
  79. bind $ctrl "<Control-p>" "::radxide::menu::edit::makePaste"
  80. bind $ctrl "<Control-x>" "::radxide::menu::edit::makeCut"
  81. bind $ctrl "<Control-f>" "::radxide::menu::edit::find"
  82. bind $ctrl "<Control-g>" "::radxide::menu::edit::GotoLine"
  83. bind $ctrl "<Return>" "::radxide::win::setNewLineWithIndent"
  84. bind $ctrl "<Tab>" "::radxide::win::insertTab"
  85. }
  86. #_______________________
  87. source [file join $::radxide::SRCDIR file.tcl]
  88. source [file join $::radxide::SRCDIR edit.tcl]
  89. }
  90. # _________________________________ EOF _________________________________ #