Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
howtos:using_with_tcl_tk [2018/04/20 17:34] – debug:Windows issues; add: fossil, ornaments aplsimplehowtos:using_with_tcl_tk [2018/04/21 06:57] – typos etc. aplsimple
Line 26: Line 26:
   * passing a selected text to the menu commands to process   * passing a selected text to the menu commands to process
  
-  * the selection can be passed as underlined ("_" instead " ")+  * the selection can be passed as underlined ("_" instead of " "), 'plused' ("+" instead of " ") or stripped of special symbols (", $, %, {}, [], <>, *)
  
   * commands can be run by itself and by shell in console box   * commands can be run by itself and by shell in console box
Line 32: Line 32:
   * commands can be run with or without waiting their completion   * commands can be run with or without waiting their completion
  
-  * internal command //%%s// means "edit/create in Geany a file(s) with name(s) = selected text" \\ (opens/creates in Geany //f1 f2 f3// files if //%s="f1 f2 f3"//+  * internal command //%%s// means "edit/create in Geany a file(s) with name(s) = selected text" \\ (opens/creates in Geany //f1 f2 f3// files if //%s="f1 f2 f3"//
-  * internal command //%"%s"// means "browse an internet link = selected text" +  * internal command //%"%s"// means "browse an internet link = selected text" 
-  * internal command //%"title" "message %s"// means "ask a confirmation, possibly with selected text"+  * internal command //%"title" "message %s"// means "ask a confirmation, possibly with selected text"
  
   * a batch of commands can be united under a single menu item   * a batch of commands can be united under a single menu item
Line 64: Line 64:
   * any menu item can be assigned to 'autorun' at start of [[using_with_tcl_tk|e_menu]] (submenus including)   * any menu item can be assigned to 'autorun' at start of [[using_with_tcl_tk|e_menu]] (submenus including)
  
-  * to 'autorun' may be assigned commands that are invisible in menu (submenus including)+  * commands that are invisible in menu may be assigned to 'autorun' (submenus including)
  
-  * any Tcl command(s) can be assigned to 'autorun' at start of [[using_with_tcl_tk|e_menu]]+  * Tcl command(s) can be assigned to 'autorun' at start of [[using_with_tcl_tk|e_menu]]
  
   * menus can be edited in Geany 'on fly' and then re-read   * menus can be edited in Geany 'on fly' and then re-read
Line 78: Line 78:
   * items can be run repeatedly at intervals set in seconds   * items can be run repeatedly at intervals set in seconds
  
-  * [[using_with_tcl_tk|e_menu]] neighboring applications can be killed with two keystrokes (well fit to clear+  * [[using_with_tcl_tk|e_menu]] neighboring applications can be killed with two keystrokes (sort of clearance)
  
   * there are a lot of 'look and feel' options (incl. highlighting 'master' or 'dangerous' menus)   * there are a lot of 'look and feel' options (incl. highlighting 'master' or 'dangerous' menus)
Line 94: Line 94:
 ===== Context action of Geany IDE ===== ===== Context action of Geany IDE =====
  
-I try and show how the Geany context command can be used with all its beauty.+I try and show how the Geany context command can be used in all its beauty.
  
 Imagine we have a Python module under testing in Geany. And it is called with parameters. And the parameters are changed from time to time. Imagine we have a Python module under testing in Geany. And it is called with parameters. And the parameters are changed from time to time.
Line 130: Line 130:
 1. If you do not have [[http://www.tcl.tk|Tcl/Tk]] on your system, install it from [[http://www.tcl.tk|www.tcl.tk]]. Linux users have it preinstalled, most likely. Though in Linux it may be necessary to install //tklib, tcl-tls// packages or even to update Tcl to 8.6 version. On Mac [[using_with_tcl_tk|e_menu]] hasn't been tested. 1. If you do not have [[http://www.tcl.tk|Tcl/Tk]] on your system, install it from [[http://www.tcl.tk|www.tcl.tk]]. Linux users have it preinstalled, most likely. Though in Linux it may be necessary to install //tklib, tcl-tls// packages or even to update Tcl to 8.6 version. On Mac [[using_with_tcl_tk|e_menu]] hasn't been tested.
  
-2. Unpack the below attached zip to save files:+2. Unpack the below attached zip to save:
  
     emenu     emenu
-    ehelp +    menus directory 
-    rarrow.png +    src directory 
-    run_pause.bat +
-    run_pause.sh +
-    ...etc...+
 into some directory, e.g. /home/me/UTILS/e_menu (for Windows it may be C:\Users\me\UTILS\e_menu). into some directory, e.g. /home/me/UTILS/e_menu (for Windows it may be C:\Users\me\UTILS\e_menu).
  
Line 209: Line 207:
 |// fs=number //|size of fonts used in menu| fs=9| |// fs=number //|size of fonts used in menu| fs=9|
 |// "f1=font" //|name of font used in menu header| "f1=Liberation Sans" | |// "f1=font" //|name of font used in menu header| "f1=Liberation Sans" |
-|// "f2=font" //|name of font used in menu entries| "f1=Liberation Mono"|+|// "f2=font" //|name of font used in menu entries| "f2=Liberation Mono"|
 |// w=number //|width of menu items (in characters)| w=30 | |// w=number //|width of menu items (in characters)| w=30 |
 |// c=number //|index of color scheme (0 through 12)| c=1 | |// c=number //|index of color scheme (0 through 12)| c=1 |
Line 221: Line 219:
 |// g=+x+y //|sets (x,y) screen coordinates of menu| g=+700+200| |// g=+x+y //|sets (x,y) screen coordinates of menu| g=+700+200|
 |// wc=1 // |centers a menu on screen|wc=1| |// wc=1 // |centers a menu on screen|wc=1|
-|// "h=path" //|path to offline Tcl/Tk help (e.g. "h=/home/me/Tcl/tcl8.6")|<nowiki>"h=/home/me/DOC/www.tcl.tk/man/tcl8.6"</nowiki>+|// "h=path" //|path to offline Tcl/Tk help|<nowiki>"h=/home/me/DOC/www.tcl.tk/man/tcl8.6"</nowiki>
-|// "b=browser" //|a browser to be used for viewing Tcl/Tk help (also used in a menu command "%link")|b=/usr/bin/epiphany|+|// "b=browser" //|a browser to be used for viewing Tcl/Tk help (also used in a menu command "%link")|b=/usr/bin/epiphany|
 |// "u=string" //|value of string that is underscored|"u=%s"| |// "u=string" //|value of string that is underscored|"u=%s"|
 |// "qq=string" //|value of string with quotes (") escaped|"qq=%s"| |// "qq=string" //|value of string with quotes (") escaped|"qq=%s"|
Line 262: Line 260:
     R:  R: 6     R:  R: 6
     R: Firefox search for "%s" R: firefox -search "%s"     R: Firefox search for "%s" R: firefox -search "%s"
-    R: Wikipedia for "%s" R:%https://en.wikipedia.org/w/index.php?cirrusUserTesting=classic-explorer-i&search=%+ +    R: Wikipedia for "%s" R:%https://en.wikipedia.org/w/index.php?cirrusUserTesting=classic-explorer-i&search=%+ 
-    R: Open/create file(s) "%s" R:%%s+    R: Open/create file(s) "%s" R:%%s
     R: geany: edit all          R: geany readme.md wiki.txt e_help.tcl e_menu.tcl     R: geany: edit all          R: geany readme.md wiki.txt e_help.tcl e_menu.tcl
          
Line 349: Line 347:
     cd $curdir     cd $curdir
  
-Notice that all three menus are called as topmost independent applications (t=1, &) without 'ornament' (o=0), the last menu running 1st item at start (//tkcon// to be exact). Geany IDE is run with project files as passed parameters. This would result in the picture shown below. All menus share some options defined with environment variables (BROWSER, DIR, LEFT) while others (PROJECT, THEME, SUBJ) are supplied to //git.mnu// only for use in git commands as %s0, %s1 and %s2 wildcards.+Notice that all three menus are called as topmost independent applications (t=1, &) without 'ornament' (o=0), the last menu running 1st item at start (//tkcon// to be exact). Geany IDE is run with project files as passed parameters. This would result in the picture shown somewhere below. All menus share some options defined with environment variables (BROWSER, DIR, LEFT) while others (PROJECT, THEME, SUBJ) are supplied to //git.mnu// only for use in git commands as %s0, %s1 and %s2 wildcards.
  
 \\ \\
Line 443: Line 441:
 A //menu item name// can begin with //F1// through //F12// which means a hotkey F1...F12 for this name. By default, items have hotkeys //1// through //9// and //a// through //z//. For example: A //menu item name// can begin with //F1// through //F12// which means a hotkey F1...F12 for this name. By default, items have hotkeys //1// through //9// and //a// through //z//. For example:
  
-    RE: F1 Geany's help RE:%file:///usr/share/doc/geany/html/index.html+    RE: F1 Geany's help RE:%file:///usr/share/doc/geany/html/index.html
  
 - this would display [[using_with_tcl_tk|e_menu]] that would display (after second F1) the help of Geany IDE and close. - this would display [[using_with_tcl_tk|e_menu]] that would display (after second F1) the help of Geany IDE and close.
Line 481: Line 479:
 |// %u0 \\  %u1 \\ -"-"- \\ %u9 //| //u0=// parameter of [[using_with_tcl_tk|e_menu]] \\ //u1=// parameter of [[using_with_tcl_tk|e_menu]] \\ -"-"- \\  //u9=// parameter of [[using_with_tcl_tk|e_menu]]| |// %u0 \\  %u1 \\ -"-"- \\ %u9 //| //u0=// parameter of [[using_with_tcl_tk|e_menu]] \\ //u1=// parameter of [[using_with_tcl_tk|e_menu]] \\ -"-"- \\  //u9=// parameter of [[using_with_tcl_tk|e_menu]]|
 |// %i0 \\  %i1  \\ -"-"- \\  %i9  //| 0th counter of runs (it may be initialized with //i0=// parameter of [[using_with_tcl_tk|e_menu]]) \\  1st counter of runs (it may be initialized with //i1=// parameter of [[using_with_tcl_tk|e_menu]]) \\ -"-"- \\  9th counter of runs (it may be initialized with //i9=// parameter of [[using_with_tcl_tk|e_menu]])| |// %i0 \\  %i1  \\ -"-"- \\  %i9  //| 0th counter of runs (it may be initialized with //i0=// parameter of [[using_with_tcl_tk|e_menu]]) \\  1st counter of runs (it may be initialized with //i1=// parameter of [[using_with_tcl_tk|e_menu]]) \\ -"-"- \\  9th counter of runs (it may be initialized with //i9=// parameter of [[using_with_tcl_tk|e_menu]])|
-|// %"link" //| calls a browser with passed //link//; here //%b// corresponds to //b=// parameter of [[using_with_tcl_tk|e_menu]]| +|// %"link" //| calls a browser with passed //link//; here //%B// corresponds to //b=// parameter of [[using_with_tcl_tk|e_menu]]| 
-|// %"title" "message" //| puts out a query with //title// and //message// asking "OK" or "Cancel"; if answered "Cancel", cancels next commands of batch| +|// %"title" "message" //| puts out a query with //title// and //message// asking "OK" or "Cancel"; if answered "Cancel", cancels next commands of batch| 
-|// %file1 [file2 ...] //| calls Geany editor to edit/create //file(s)// e.g.: \\  ... to edit file(s) of Geany's selection: \\     //%%s// \\  ... to edit/create all files of project by one click: \\     // %mod1.c mod2.c mod3.c mod4.c mod1.h mod2.h mod3.h mod4.h etc.//|+|// %file1 [file2 ...] //| calls Geany editor to edit/create //file(s)// e.g.: \\  ... to edit file(s) of Geany's selection: \\     //%%s// \\  ... to edit/create all files of project by one click: \\     // %mod1.c mod2.c mod3.c mod4.c mod1.h mod2.h mod3.h mod4.h etc.//|
 |// ''<nowiki>%%</nowiki>'' //| % symbol| |// ''<nowiki>%%</nowiki>'' //| % symbol|
 |// %d //| Geany's wildcard %d (reserved)| |// %d //| Geany's wildcard %d (reserved)|
Line 558: Line 556:
          
      R: Firefox search for "%s" R: firefox -search "%s"      R: Firefox search for "%s" R: firefox -search "%s"
-     R: Wikipedia for "%s"      R: %https://en.wikipedia.org/w/index.php?cirrusUserTesting=classic-explorer-i&search=%++     R: Wikipedia for "%s"      R: %https://en.wikipedia.org/w/index.php?cirrusUserTesting=classic-explorer-i&search=%+
          
     MW/ Git menu               MW/ "m=menus\gitmenu.txt" o=0 "PD=%d" "s=%s"     MW/ Git menu               MW/ "m=menus\gitmenu.txt" o=0 "PD=%d" "s=%s"
Line 578: Line 576:
 The wildcard //%s// refers to Geany's selection. The wildcard //%dd// is the same as //%s// but it's used to get rid of special symbols as ", $, %, {, }, [, ], <, >, *. The wildcard //%s// refers to Geany's selection. The wildcard //%dd// is the same as //%s// but it's used to get rid of special symbols as ", $, %, {, }, [, ], <, >, *.
  
-The wildcard //%q// is a query with 'title' and 'query text'. Being answered 'Cancel' it cancels the execution of batch.+The wildcard //%Q// is a query with 'title' and 'query text'. Being answered 'Cancel' it cancels the execution of batch.
  
-In // %// command you should use edging double quotes and internal single quotes in a title and a message. Symbol \//n// stands for an empty line.+In // %// command you should use edging double quotes and internal single quotes in a title and a message. Symbol \//n// stands for an empty line.
  
     # git menu for e_menu     # git menu for e_menu
Line 593: Line 591:
     S:git add * S: git add *      S:git add * S: git add * 
          
-    R:git commit -m "%dd" R: %"Committing changes" "Commit with message\n\n'%dd' ?"+    R:git commit -m "%dd" R: %"Committing changes" "Commit with message\n\n'%dd' ?"
     R:git commit -m "%dd" R: cd %PD     R:git commit -m "%dd" R: cd %PD
     S:git commit -m "%dd" S: git commit -m "%dd"     S:git commit -m "%dd" S: git commit -m "%dd"
          
-    R:git commit -am "%s" R: %"Committing changes" "Add and commit with message\n\n'%s' ?"+    R:git commit -am "%s" R: %"Committing changes" "Add and commit with message\n\n'%s' ?"
     R:git commit -am "%s" R: cd %PD     R:git commit -am "%s" R: cd %PD
     S:git commit -am "%s" S: git commit -am "%s"     S:git commit -am "%s" S: git commit -am "%s"
          
-    R:git log --since="1 day ago" R: cd %PD +    R:git log "--since=1 day ago" R: cd %PD 
-    S:git log --since="1 day ago" S: git log --since="1 day ago"+    S:git log "--since=1 day ago" S: git log "--since=1 day ago"
          
-    R:git log -p --since="1 day ago" R: cd %PD +    R:git log -p "--since=1 day ago" R: cd %PD 
-    S:git log -p --since="1 day ago" S: git log -p --since="1 day ago"+    S:git log -p "--since=1 day ago" S: git log -p "--since=1 day ago"
          
     MW: Others MW: m=menus/git2.mnu w=40     MW: Others MW: m=menus/git2.mnu w=40
Line 659: Line 657:
 It's also assumed in the next sections that [[using_with_tcl_tk|e_menu]] has been unpacked into //C:\UTILS\e_menu// directory. It's also assumed in the next sections that [[using_with_tcl_tk|e_menu]] has been unpacked into //C:\UTILS\e_menu// directory.
  
-Try [[using_with_tcl_tk|e_menu]] now. Set the caret on a word of your text edited in Geany IDE. You may also select a piece of text. Call //'Context action'// from popup menu or by a hotkey mapped to it.+Try [[using_with_tcl_tk|e_menu]] now. Set the caret on a word of your text edited in Geany IDE. You may also select a piece of text. Call //'Context action'// from popup menu or with a hotkey mapped to it.
  
 You should see the following: You should see the following:
Line 686: Line 684:
     wget -r -k -l 2 -p --accept-regex=.+/man/tcl8\.6.+ https://www.tcl.tk/man/tcl8.6/     wget -r -k -l 2 -p --accept-regex=.+/man/tcl8\.6.+ https://www.tcl.tk/man/tcl8.6/
  
-Now the offline help should be ready to call. If not, check the version of your //wget// utility. You may also check //C:\UTILS\e_menu\e_help.tcl// for the strings containing //htm// links to the offline help.+Now the offline help should be ready to call. If not, check the version of your //wget// utility.
  
 Retry [[http://www.tcl.tk|Tcl/Tk]] help calling. Select in your text (or place the caret on), for example, //package// and call Geany's context action. You should see something like: Retry [[http://www.tcl.tk|Tcl/Tk]] help calling. Select in your text (or place the caret on), for example, //package// and call Geany's context action. You should see something like:
Line 699: Line 697:
 Let's try and create a simple menu of 2 commands that would be available from Geany's context. Let's try and create a simple menu of 2 commands that would be available from Geany's context.
  
-The menu file will be //C:\UTILS\e_menu\test1.mnu//. We shall use commands that process Geany's selected text to:+The menu file will be //C:\UTILS\e_menu\menus\test1.mnu//. We shall use commands that process Geany's selected text to:
  
   * seek the selected internet pages   * seek the selected internet pages
   * view the selected words in a dictionary   * view the selected words in a dictionary
  
-Fill the //C:\UTILS\e_menu\test1.mnu// with the following:+Fill the //C:\UTILS\e_menu\menus\test1.mnu// with the following:
  
     R/ Firefox search for "%s" R/ ""C:\Program Files (x86)\Mozilla Firefox\firefox.exe" -search "%s"     R/ Firefox search for "%s" R/ ""C:\Program Files (x86)\Mozilla Firefox\firefox.exe" -search "%s"
Line 786: Line 784:
     SW: echo %%PD is %PD SW: echo %%PD is %PD     SW: echo %%PD is %PD SW: echo %%PD is %PD
          
-    R: git init R: %"Init GIT" "Are you sure to init git in\n\n%PD ?"+    R: git init R: %"Init GIT" "Are you sure to init git in\n\n%PD ?"
     R: git init R: cd %PD     R: git init R: cd %PD
     S: git init S: git init     S: git init S: git init
Line 799: Line 797:
     S: git add * S: git add *      S: git add * S: git add * 
          
-    R: git commit -am '%s0' R: %"Committing changes" "Do you really want to commit with message\n'%s0' ?"+    R: git commit -am '%s0' R: %"Committing changes" "Do you really want to commit with message\n'%s0' ?"
     R: git commit -am '%s0' R: cd %PD     R: git commit -am '%s0' R: cd %PD
     S: git commit -am '%s0' S: git commit -am "%s0"     S: git commit -am '%s0' S: git commit -am "%s0"
Line 910: Line 908:
 Here the Tcl commands are used to exit and close the dangerous menu possibly open by mistake. Q is a query with "head" and "message" that can contain the above mentioned wildcards. Q returns 'false' if answered 'Cancel' so that 'exit' Tcl command closes the menu. Here the Tcl commands are used to exit and close the dangerous menu possibly open by mistake. Q is a query with "head" and "message" that can contain the above mentioned wildcards. Q returns 'false' if answered 'Cancel' so that 'exit' Tcl command closes the menu.
  
-When calling a menu item, you can use //%"head" "message"// in a command batch. It's the same query with the difference that [[using_with_tcl_tk|e_menu]] stops the batch of commands after answering 'Cancel'. For example:+When calling a menu item, you can use //%"head" "message"// in a command batch. It's the same query with the difference that [[using_with_tcl_tk|e_menu]] stops the batch of commands after answering 'Cancel'. For example:
  
-    R:git reset --hard HEAD R: %"RESET" "This cancels the last uncommitted changes and resets to the last commited state!\n\nDo you want to RESET ?\n\n(VERY LIKELY IT'S CANNOT BE UNDONE)"+    R:git reset --hard HEAD R: %"RESET" "This cancels the last uncommitted changes and resets to the last commited state!\n\nDo you want to RESET ?\n\n(VERY LIKELY IT'S CANNOT BE UNDONE)"
     R:git reset --hard HEAD R: cd %PD     R:git reset --hard HEAD R: cd %PD
     S:git reset --hard HEAD S: git reset --hard HEAD     S:git reset --hard HEAD S: git reset --hard HEAD
Line 933: Line 931:
   * // %i9 // - are counters of item runs   * // %i9 // - are counters of item runs
  
-It's useful feature for commands that are logging or marking their data (files, directories etc.) with a current time, date and/or counter. There are 10 run counters per a menu and time/date formats that can be set at call.+It's useful feature for commands that are logging or marking their data (files, directories etc.) with a current time, date and/or counter. There are 10 run counters per a menu and 10 time/date formats that can be set at call.
  
 Here is a typical example: Here is a typical example:
Line 991: Line 989:
 Insert into "menus/menu.mnu" the following line (it will be useful by itself in future): Insert into "menus/menu.mnu" the following line (it will be useful by itself in future):
  
-    R: Open all R: %readme.md wiki.txt e_help.tcl e_menu.tcl+    R: Open all R: %readme.md wiki.txt e_help.tcl e_menu.tcl
  
 ... and assuming that "Open all" entry is number 8 in menu.mnu, change its call so: ... and assuming that "Open all" entry is number 8 in menu.mnu, change its call so:
Line 1022: Line 1020:
          
     R: Run periodic reminding of rest at 45 min interval R: ?-45*60/-15*60? stopwork_arbeiten %TI     R: Run periodic reminding of rest at 45 min interval R: ?-45*60/-15*60? stopwork_arbeiten %TI
-    R: Run batches of commands periodically R: ?60*60-2/-1:a=4,5/-1:ah=1,2? begin_of_batch 
  
-The last two tasks should be explained in details. The common format of periodic command is following:+The last task should be explained in details. The common format of periodic command is following:
  
     ?NSEC/NSEC1:a=n1,n2/NSEC2:ah=n3,n4/.../TN=X:ah=n5/? TASK_COMMAND %TI     ?NSEC/NSEC1:a=n1,n2/NSEC2:ah=n3,n4/.../TN=X:ah=n5/? TASK_COMMAND %TI
Line 1195: Line 1192:
  
 Also, the applied tool, namely the great and awful Tcl/Tk would never stop to amaze as well. Though the first impression of Tcl is 'What a s...!' Second, third, fourth and ..th impressions are the same till one day this thing begins to tease your brains and make to wonder. Also, the applied tool, namely the great and awful Tcl/Tk would never stop to amaze as well. Though the first impression of Tcl is 'What a s...!' Second, third, fourth and ..th impressions are the same till one day this thing begins to tease your brains and make to wonder.
 +
 +An unexpected and pleasant discovery had occurred while me coding [[using_with_tcl_tk|e_menu]], namely the wonderful [[http://fossil-scm.org|Fossil VCS]]. Somehow its power and lightweight resemble Geany's.
  
 And these wonders tend to become //a movable feast//. And these wonders tend to become //a movable feast//.
Line 1207: Line 1206:
 More screenshots of [[using_with_tcl_tk|e_menu]]: More screenshots of [[using_with_tcl_tk|e_menu]]:
   * https://github.com/geany/geany/issues/1808   * https://github.com/geany/geany/issues/1808
 +
 +A sort of proposal:
 +  * https://github.com/geany/geany/issues/1836
  
 A sort of conversation: A sort of conversation:
Print/export