main.tcl 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. ###########################################################
  2. # Name: main.tcl
  3. # Author: Daniele Bonini (posta@elettronica.lol)
  4. # Date: 25/11/2023
  5. # Desc: Main namespace of RadXIDE.
  6. #
  7. # Main 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. namespace eval main {
  20. # ________________________ Main _create _________________________ #
  21. proc _create {} {
  22. # Creates the main form of radxide.
  23. namespace upvar ::radxide dan dan
  24. ::radxide::win::makeMainWindow $dan(WIN).fra $dan(TITLE) $dan(BG) $dan(FG)
  25. }
  26. # ________________________ ShowHeader _________________________ #
  27. proc updateAppTitle {} {
  28. # Displays a file's name and modification flag (*) in alited's title.
  29. namespace upvar ::radxide dan dan project project
  30. #tk_messageBox -title $dan(TITLE) -icon error -message $project(CUR_FILE_PATH)
  31. set f "<no file>"
  32. if {$project(CUR_FILE_PATH) ne ""} {
  33. set f [string range $project(CUR_FILE_PATH) [expr [string length $dan(WORKDIR)]+1] end]
  34. }
  35. #tk_messageBox -title $dan(TITLE) -icon error -message $f
  36. set t $dan(TITLE)
  37. set templ $dan(TITLE_TEMPL)
  38. set ttl [string map [list %f $f %t $t] $templ]
  39. wm title $dan(WIN) [string trim $ttl]
  40. }
  41. # ________________________ Main _run _________________________ #
  42. proc _run {} {
  43. # Runs the alited, displaying its main form with attributes
  44. # 'modal', 'not closed by Esc', 'decorated with Contract/Expand buttons',
  45. # 'minimal sizes' and 'saved geometry'.
  46. #
  47. # After closing the alited, saves its settings (geometry etc.).
  48. namespace upvar ::radxide dan dan
  49. wm attributes $dan(WIN) -topmost
  50. updateAppTitle
  51. wm iconphoto $dan(WIN) $dan(ICONI)
  52. wm resizable $dan(WIN) 1 1
  53. ::radxide::win::centerWin $dan(WIN) $dan(WIDTH) $dan(HEIGHT)
  54. wm minsize $dan(WIN) [expr $dan(WIDTH)-600] [expr $dan(HEIGHT)-600]
  55. wm maxsize $dan(WIN) [expr $dan(WIDTH)+400] [expr $dan(HEIGHT)+300]
  56. wm attributes $dan(WIN) -fullscreen 0
  57. wm protocol $dan(WIN) WM_DELETE_WINDOW { radxide::quit }
  58. catch {focus -force $dan(TEXT)}
  59. # Modal
  60. set var 1
  61. ::radxide::win::waitWinVar $dan(WIN) $var 1
  62. # --
  63. destroy $dan(WIN)
  64. update
  65. return 1
  66. }
  67. }
  68. # _________________________________ EOF _________________________________ #