		------------------------------------------------------
		
	
	[?] Using Help:
		Back to Top
		  - After clicking hyperlink, reading and wanting to go back to top,
			Press arrow left or right --> back to top (if not clicked anywhere)
			
	
	[2] While searching:
			Ctrl-n  Next match
			Ctrl-p  Prev match
			Ctrl-Tab   Insert Tab
			Up/Down    Walk history
			
			-	Copying text to clipboard is possible with yank-line etc.
			-	Add bookmark is possible, so is Goto def from which:
				arrow-key or Ctrl-np -> back to matches
			-	Changing replacement string is possible while replacing.
			-	1: Press Space to exit search to focus.
				2: Double-click to exit to cursor.
				3: Press Esc to exit to cursor position at the start of the search.
				Press arrow-key to refresh view back to cursor, if necessary.
		
		After searching, show and select next/prev occurence of last search
		(if no selection, else uses selection) Also known as: search again
			Ctrl-n  Next match
			Ctrl-p  Prev match

		While replacing:
			Press Return once to replace, press again to move to next match,
			(pressing again does not yet replace that next match)
			
			Matches can be skipped with Ctrl-np
			
			
		Cmd/Alt-r	Toggle regexp
		Cmd/Alt-i	Toggle search starts at insert/filestart
		
		
		
		Default bindings: https://tcl.tk/man/tcl9.0/TkCmd/text.html#M192
		
		-------------------------------------------------------------
						

	.----------------------------------------------------.
	|Below this, it is expected one started editor with: |
	|													 |
	|	import henxel 									 |
	|	e=henxel.Editor()								 |
	|													 |
	|This is then referenced like:						 |
	|	e.bookmarks_print()								 |
	*----------------------------------------------------*
	
	
	Using as normal editor
		Editor can be launched from terminal and with arguments, for example:
		python -m henxel ../../dir1/dir2/*.txt *.py
		
		or just:
		henxel ../../dir1/dir2/*.txt *.py
		
		1: Editor is then launched using 'one time conf': setting is same
		but original tabs are not opened, and nothing is saved in conf.
		2: Do something, close editor. When restarting normally(no file-arguments)
		--> original tabs are opened
		
		Note for Powershell users: type: $(dir *.txt) in place of *.txt
	
	
[3] When is my file Saved to Disk?
	
		All tabs are saved to disk when:
		  - closing program, also configurations
		  - running file
		  - doing test-launch
		
		Current tab is saved to disk when:
		  - closing tab, if it had filename.
			New tabs get filename by pressing save.
		  
		  - opening file from disk when there already was another file opened
			in tab.
			
		  - choosing "chk syntax" from popup-menu
		
		  - Pressing Save-button
		
		This means that if you want to cancel recent changes:
		  - do not run file
		  - do not close editor
		  - do not close tab with a filename
		  - do not open file in a tab which has already a file opened
		  
		  - instead close python-console with ctrl-d
		
	
	Editor
	  - Editor configuration is related to python-environment (sys.prefix)
		in which python console was launched. So if you have say two
		different envs in the same directory, they will have separate confs.
		
	  - If editor was not launched from virtual environment,
		configuration is saved in home-directory. This means editor
		can also be used in 'normal' python environment.
		
	  - If editor was launched inside a directory what is being
		version-controlled with git, the current git-branch will be shown
		in top-left corner. (info on setting other version control program
		is below )
		
	  - If you do something in python-console that waits for user input,
		Editor will be freezed during that time, like when viewing help
		of some function.
		
	  - When not debugging, pressing close-button exits editor even if there
		are errors, even saving errors.
		Cmd/Ctrl-q does not exit editor in such cases.
		
	  
[4] Save-button
	  - To create a new file, add filename to entry and press save.
	  	This creates an empty file like 'touch'. This is done to
		ensure filepath is ok. Contents will be saved to disk in
		above mentioned situations.
		
		Examples:
		A: Save to directory where python console was launhed:
			filename.py
		B: Save to subdirectory, counted from launch directory:
			sub1/sub2/filename.py
		C: Save to any directory, counted as before:
			../../dir1/dir2/filename.py
		
	  - If a file was already open and user changed filename in entry,
		old file is first saved (but not to disk) and then new file with
		same content is created in a new tab (its contents are not yet in disk).
	  
	  - If, for example need current tabs content for external use, it is
		possible to sync current tab to disk by pressing Save-button or by
		choosing: "chk syntax" from popup-menu. It saves any file,
		not just py-files.
		
	  - Contents of tabs without filename are not saved when closing tab,
		or program, but tabs are still kept as placeholders.
			
		
	Open-button
	  - When in tab without filename, files can be opened from entry
		or by pressing button.
	  
	  - If tab had filename and user changed filename in entry and
		user presses enter: old file is first saved to disk and closed,
		then filepath in entry is opened in the same tab.
		
	  - If entered filename in entry and pressed open, entry is ignored.
	
	  - Files from disk are always opened into current tab,
	  	old file is saved and closed but bookmarks are gone
	  	--> When planning opening new file from disk,
			check is current tab something one wants to keep open,
			or does it have important bookmarks.
			If is, then open new tab first, and then open file to it.
			
	  - It is good practise to always: open newtab, open file

	
	i-button
	  - Toggle setting-console in which can edit settings just like
		in python-console: e.search_setting_edit() etc.
	  - If wrote: e.boo and hit Tab: get all possible completions.
	  - Press Control-h to open help on current item.
	  - If using ee instead of e, get whole namespace of editor-instance
		anf if using just single e, get only settings
	  - Nice to know:
	  	Control-a  Move cursor to linestart
	  	Control-k  Kill from cursor to lineend
		Up/Down    Walk history
		
	  - Getting help on very common stuff, help(str), list, dict etc:
		For example, to look help on string-methods, enter 'str' to entry
		and press Control-h
		
	  - Sometimes, if output from command is missing, activating terminal
		might help.
	  - Close console with Esc
	
	
	Selection
	  - Long selection: if cursor is not visible,
		to show wanted side of selection, toggle left/right -keys
		
	  - When doing "select scope" and if got too long selection,
		to cancel it, do not press left/right, instead press Esc.

	
[5] Executing program
	  - Code does not have to have filename, just write something and
		select "runfile" from popup-menu (Alt-m)
	 
	  - Run file with filename: select "runfile" from popup-menu
	 
	  - Run bigger projects: select "run module" from popup-menu
		(Also, See next section about these settings)
	
	
[6] Doing Test-run
	  - input from stdin does not work, so use test-data for that.
	  
	  - Editor freezes when running a program, but it should be possible
		to terminate program with ctrl-c from python-console.
	
	  - Settings involved in short, see help for more info
		e.timeout_set		default:1 (plus 1 sec delays)
		e.run_module_set	Use this
		
		e.custom_run_cmd_set	Just in case
		e.popup_run_action_set	1: run module (default)
								2: run custom
	
	
[7] Refreshing syntax-highlighting
	  - If highlighting looks wierd, choose 'draw syntax' from popup-menu.
	  - Note that it might not get any better if there is some
		syntax-error in the code. Fix the error then redraw.
	  - To know where that error is, do: run
		(if debugging do: test-launch)
		or if not wanting to do run, to check syntax of current tab:
		from popup: chk syntax
	  - Single line syntax can be refreshed by adding space
		and then deleting it. Multiline strings: If string has correct
		triples, then again: just insert and delete space inside string.
		Else, fix quotation-marks then redraw.

	
[8] Check syntax
	  - Of current tab: from popup-menu: "chk syntax"
	  - Of all open py-files: popup: run or test-launch
		or, if don't want run:
		e.save_forced() --> True if no saving errors, then:
		e.tab_has_syntax_error() --> False if no syntax errors
	  
	  Should syntax of open py-files be checked at exit?
	  e.check_syntax_on_exit()
	
	  - Without arguments, return current setting
	  - 1: do check (default)
	  - 0: no check
	
	
[9] Bookmarks
	  - Are very useful
	  - Create/remove bookmark with Cmd/Alt-p
	  - Hide bookmarks with Cmd/Alt-u (if have too many, so it is easier
		to navigate. They can be restored later)
		
	  - Walk bookmarks with Cmd/Alt-bB
	  - Can also be created while searching:
		Easy: Press Cmd/Alt-p to bookmark match with focus
		Or You can scroll, Goto def etc, and when find something interesting
		Click there and Press Cmd/Alt-p to bookmark that position
		
	  - Are saved in configuration. Note: currently only open files can have
		bookmarks. When tab is closed its bookmarks are gone, but editor will
		ask for confirmation before you close tab with bookmarks
		
	  - There is no shortcuts for:
		e.bookmarks_remove() --> from current tab
		e.bookmarks_remove(all_tabs=True) --> from all tabs
		e.bookmarks_print() of current tab
		
		With this one can save bookmarks if need for example; close tab
		but want to keep record of its bookmarks, just note that
		overwriting to same file multiple times will delete old bookmarks
		in that file. This will save also stashed bookmarks
		e.bookmarks_export()

		e.bookmarks_import() --> update (add not already existing),
			update opened tabs bookmarks from file
			Note: does not work while in fullscreen
		e.bookmarks_unstash() --> restore hided bookmarks to tab
		e.bookmarks_unstash(all_tabs=True) --> to all tabs

		To remove just one hided bookmark, first check linenumber with:
		1: e.bookmarks_print()
		2: Goto that line with stashed bookmark
		3: bookmark: Cmd/Alt-p on that line, this removes hided bookmark
		4: and if not want leave this new bookmark, again: Cmd/Alt-p
		

[10] Goto definition
	  - Of function in current tab with Cmd/Alt-g
		when cursor is at or in between: self.w<INS>alk_scope<INS>
		(or if there is selection, uses it)
	  - Can be done also while searching,
		just press arrow-key or Ctrl-np to get back to matches,
		because esc will exit search.
	  - Bookmarks can be created while doing goto def
	  - Esc: exit to cursor position at the start of search/gotodef
	  - Space: exit to definition line
	  - One can also select function of interest while searching,
		other than on match, and press Alt-g to get there.
		Or just click the function name, then press Alt-g
		
	  - Note: when doing multiple gotodefs in a row,
		pressing arrow key returns view to previous place,
		where gotodef was executed. That means one can go one
		'step' back but no more. This applies search also, so
		again, ctrl-np is a safe choise while searching.
		
	
[11] Set editor size and position
	  - help(e.use_geometry)
	  - Editor is normally using default size and positioned on top-right corner
	  - One can choose to let window manager do everything with:
		  e.use_geometry(False)
		
	  - Restore default setting:
		  e.use_geometry('default')
		
	  - Save current geometry:
		  e.use_geometry('current')
		
	  - Show(does not edit setting) current full geometry-string
		  e.geometry() or
		  e.wm_geometry()
		
	  - Change position (to top-left corner)
		(note using of geometry instead of use_geometry, this is for
		some reasons. One can play with this, and once happy give full
		geometry_string as in Usage Example below)
		  e.geometry('+0+0')
		
	  - Change size
		(note using of geometry instead of use_geometry.
		One can play with this, and once happy, give full geometry_string
		as shown below in: Change size and position)
		  e.geometry('881x600')
		
	  - Change size and position
		  e.use_geometry('881x600+0+50')
		  This setting will then be used at next startup onwards.		
	  
	  Usage Example
	  Drag editor-window to place one likes. Resize it to size one wants.
	  Then call: e.use_geometry('current')

	
[12] Set editor to launch fullscreen
	  e.editor_starts_fullscreen()  --> current value
	  e.editor_starts_fullscreen(1) --> start fullscreen
	  e.editor_starts_fullscreen(0) --> normal start
	
	
[13] Set command to fetch current version control branch
	  - By default if using git, nothing needs to be done	
	  - Command must be given as list. Command is tried before
		setting. You can split command string to list with split,
		or use shlex-modules split.
	
		Example, default commands splitting:
		  cmd_as_list = 'git branch --show-current'.split()
		Then:
		  e.version_control_cmd_set(cmd_as_list)

	  - On success, the new command is saved in configuration
	
	
[14] Tab-completion
	  - When starting to write object-name that has already been used
		somewhere in contents like:
		
			self.at
		
		then when hitting TAB, editor searches all matches in contents which
		starts with self.at and shows them one by one when pressing again TAB
		until all matches have been showed.
			
			self.attribute1
			
		If expansion got too long, one can delete to previous dot with:
			self.attribute1.extra<INS>
			--> Cmd/Alt-BackSpace
			--> self.attribute1.
			
	  - Only single 's' is needed to expand to: self.
	  - Hide completion-window with arrow up/down
	  - Cancel completion with Esc

	
[15] Inspecting modules
	  - Just write the name of the module, like tkinter.font in the editor,
		select it and choose 'open mod' from popup-menu. Then search.
				
	
[16] Pasting diff output to editor
	  - When want to paste diff output lines, they must be cleaned from
		indicator characters, like "+" in git diff.
		1: Paste lines 
		2: From popup-menu, select "strip one", or use shortcut:
			Ctrl-Shift-K
			--> it will remove first character from every line of selection	
		3: Ensure you still have selected pasted lines and press Ctrl-t
		4: Done
		
	
[17] Fix possible printing issue with macOS
	  - If using macOS, printing from editor might not work when launched
		from Python-console
		
	  - For example line-wrapping could be missing and there could be
		only linefeeds, no translation: \n --> CR+LF
		This change came in about Python 3.13, but printing might work
		in newer macOS versions than 12.
		
	  --> If having issues with printing: e.mac_print_fix_use(1)
		Without arguments, it returns current setting.
		e.mac_print_fix_use(1): Use fix,  0: Use normal print
		
		This is then saved in configuration
	  
	  - By default, normal printing is used on all platforms.
	  - If editor is launched from terminal, normal printing is used
		even when this setting is on.
		
	
[18] Selecting range of lines
	  - Start goto line and use comma "," to select range, like:
	
		1: "10,30" (normal) 2: ",33" (from ins, to 33) 3: "1," (from 1, to ins )
		4: ",+2" (from ins, to ins+2) 5: "-2,end-2" (from ins-2, to end-2)
	 
	  - Empty means insert and -+ is counted from it.


[19] Guiding
	  - There are no guides, but cursor can be used as a poor mans guide.
		Except that normal cursor is not very good guide, so:
		Enter search, but don't actually search anything. Now put cursor
		on start of block/line that needs indentation-check. Then scroll up,
		notice how this cursor does not move but goes just straight up and down
		making it an excellent guide. Make check and esc away search afterwards.


[20] Elide
	  - Eliding is work-in-progress, it works but is not fully implemented:
		For example, searching, gotoing is not done. Nested eliding, not done.
		And is not preserved.
	
	
[21] Search and Replace
		
		Resources:
			e.search_help_print()
			e.search_setting_print()
			e.search_setting_reset()
			help(e.search_setting_edit)
			
			https://www.tcl.tk/man/tcl9.0/TkCmd/text.html#M147
			https://www.tcl.tk/man/tcl9.0/TclCmd/re_syntax.html
			https://www.tcl.tk/man/tcl9.0/TclCmd/regexp.html
		
		
	  - Good news is, most of the time these are not needed.
	  - When are, it most likely is:
			
			e.search_setting_edit('-start insert')
		
		This changes searching to start from insertion cursor
		
		If that won't help, below is couple more examples
	
	
[22] Substitution with Regexp
		NOTE: One has to use double backlash for capture group references
		in new_word, like: \\1 instead of just \1 
		
	  - Example 1 Begin (moving/copying columns)
		If contents of tab is
		
		Example: 121 212
		
		Example: 121 212
		
		Example: 121 212
		
		
		And there is "-regexp" in search_setting, and doing replace
		
		Then if search_word(old_word) would be
		"(\d+) (\d+)"
		And if substitution(new_word) would be
		"\\2 \\1"
		
		Result after replacing would then be (moving colums)
		Example: 212 121
		
		Example: 212 121
		
		Example: 212 121
		
		And if substitution(new_word) would be
		"\\2 \\1 \\1 \\2" --> copying colums
		Example 1 End


	  - Example 2 Begin (about nested capture order)
		
		line in tab before: "123ABCDEF321"
		
		search_word: "3(A(B)(C))(D(E)(F))3"
		
		new_word: " \\1 \\2 \\3 \\4 \\5 \\6 \\0 "
		
		line in tab after: "12 ABC B C DEF E F 3ABCDEF3 21"
		(\\0 is whole match)
		Example 2 End
		
	
	- Example 3 Begin (Add decorator to function definition)
		note, capture group 1 gets indentation
		
		search_word: (^[[:blank:]]*)def.*$
		
		new_word: \\1@mydecorator\n\\0
		
		Example 3 End

		
		Some more info, examples below are search_word(old_word)
			Adding to linestart: "^"
			Adding to lineend: "$"
			Concatenate lines: "\n+"

	
[23] Set left margin
	  A: Set total distance from left edge of editor window to start of text
	  for normal window, and possible separate width for fullscreen.
	  Recommended to use same margin for both, but they can be different
	  if for example want 'centered view' in fullscreen view.
	  Without arguments, prints current setting.

	  - reset both to defaults
		e.left_margin_set(0)

	  - reset only margin of normal window
		e.left_margin_set(0, e.margin_fullscreen)
		
	  Examples
	  - set different margin for normal window and fullscreen
		e.left_margin_set(10, 20)
		
	  - set same margin for normal window and fullscreen
		e.left_margin_set(10)
		
	  - change only margin for normal window (to 10)
		e.left_margin_set(10, e.margin_fullscreen)
		
	  - change only margin for fullscreen window (to 20)
		e.left_margin_set(e.margin, 20)
		
		
	  B: Set distance(length of empty space) from linenumbers to start of text,
	  for normal window, and possible separate width for fullscreen.

	  This does not change total distance of left_margin. After using this, one
	  can increase lenght of total margin, with left_margin_set, if necessary.
	  Without arguments, prints current setting.

	  - Reset both to defaults:
	    left_margin_gap_set(0)

	  - Reset only gap of normal window:
	    left_margin_gap_set(0, self.gap_fullscreen)

	  distance can be int --> pixels
	  or string like 1c --> note, this adds much space

	  Example: left_margin_gap_set(10, '2c')

	
[24] Set scrollbar width
	  - e.scrollbar_widths_set(width, elementborderwidth)
	
	
[25] Set filedialog sorting order (directories, files)
	  - e.filedialog_sorting_order_set()	--> current values
	  - e.filedialog_sorting_order_set(0,0)	--> both 'normal'
	  - e.filedialog_sorting_order_set(1,1)	--> both reversed
	  - default is (1,0) (directories with capital first letter last)
	
	
[26] Change tabsize
		Size can be 1-8, default is 4
		
		Change size for all files:
	  - e.tabsize_change(8)
		
		For code-snippet:
	  - If you copied something to your editor that has different indentation
		than rest of the file:
		(Note that you don't have to do anything if it is indented with normal
		4 spaces and you have indent-depth the normal 4 )
		1: Make sure you copied the block starting with one empty line.
		2: Click cursor to start of empty line and paste.
		
		Then select that code and press Ctrl-t, and
		it should then be indented as you wanted and you can then continue
		indenting the pasted code to the right place.
		
		(Note that you don't have to do anything if you open a file that has
		different indentation than your setting, it is changed automatically
		and saved with tabbed indentation after you for example close it.)
	
	
[27] Export configuration
	  - If wanting to use current configuration on many environments,
		it can be exported with e.export_config(). It sets e.geom to False
		so one must do: e.use_geometry('default') after first launch with
		that conf. It also does not have any tabs or bookmarks etc.
		Name of conf-file has to be 'henxel.cnf' and it has to be in
		python env-directory, when in use.
		
		For example: One has nice working conf in some project and thinks
		about using it as default for some new projects: 1: e.export_config
		2: Start new project 3: cd mynew_project/my_python_venv_folder
		4: cp path_to_exported_conf . 5: launch henxel
	

[28] Developing
	  -	When editor is in debug-mode, Cmd/Control-q will do syntax checking
		on all open python-files regardless of check_syntax setting
		and if that passes, test-launch. After succesful test-launch editor exits.
	  
	  - If editor does not launch after making some changes, error message and
		info about recovering is printed. See: help(henxel.stash_pop)
	
	
	
	  - Starting debug-session, all platforms:
		This is most useful way to start debugging for several reasons.
		One reason: Fast to start debugging: Control-r in terminal to search history
		and enter "deb" and it should give this command right away.
		
		from terminal: python -m henxel --debug
		
		Or from Python-console (if wanting to have real Python-console):
		import henxel
		e=henxel.Editor(debug=True)
		
		
		Q: When to start from terminal?
		A: Always, or at least if having problems seeing tracebacks.
		Sometimes, like errors from eval-lines, errors from nested callbacks
		(callback was defined in callback), has to use try-block, but
		
		try @debug -decorator first: place '@debug' above buggy callback, like
			
			@debug
			def bugs_here(): return 1/0
		
		
	  - More info is in function: e.build_launch_test
	
	  - If using macOS and have issues with error messages, first read
		section above about how to: Fix possible printing issue with macOS.
		Then add @debug decorator on top of buggy callback, and then can
		debug with print-lines also. Or just launch with mainloop(==from terminal)
		
	
	
	Homepage: https://github.com/SamuelKos/henxel
	
	
