Changes

Jump to navigation Jump to search
686 bytes removed ,  08:25, 29 December 2017
no edit summary
[https://foicica.com/textadept/ Textadept] is a programmable text editor for Linux, Mac OSX and Windows. It is fully extensible using [https://www.lua.org/ Lua].
= How to ConTeXt with Textadept (MS Windows) =(updated 2017/0312)
== Step 1: Install / Update '''ConTeXt''' ==
* If a message like '''context' is not recognized as an internal or external command...'' appears, you should restart your machine, make sure that you added the correct location of ConTeXt's executables path to Window's search path or re-try the operation by starting from Step 2.1.
== Step 3: Install '''ConTeXt with Textadept''' =(MS Windows) =(updated 2017/12)
3.== Step 1. [https://foicica.com/textadept/download/textadept_LATEST.win32.zip Download] and extract [https://foicica.com/textadept/ Install '''Textadept'''] to a folder of your choice.==
31.21. Use <code>[https://foicica.com/textadept/download/textadept_LATEST.win32.zip Download] and extract [https://foicica.exe<com/textadept/code> from the extracted '''Textadept'''] to a folder to start Textadeptof your choice.
1.2. Use <code>textadept.exe</code> from the extracted folder to start Textadept. == Step 42: Tweak '''Textadept''''s settings ==
'''Note''' that almost all changes to Textadept are saved in the file <code>init.lua</code>. There is two of them, of which you should edit only one:
Save <code>init.lua</code> and restart Textadept once. After doing so you can add changes to Textadept's configuration files and press <code>F9</code>-key afterwards to save and load the changes without having to restart Textadept.
=== Step 42.1: Bind a PDF build command into Textadept ===
42.1.1. Use Textadept to open your <code>init.lua</code> stored in <code>SYSDRIVE:\users\USER\.textadept\</code>.
42.1.2. Add an execute command for ConTeXt to Textadept's menu:* If your ConTeXt executables folder is already in the Windows search Path:
textadept.run.compile_commands.tex = 'mtxrun --autogenerate --script context --autopdf --purge --synctex=-1 "%f"'
* If for some reason you can't add the folder to PATH, for example on public machines, you have to add the full path to your ConTeXt executables. For example: textadept.run.compile_commands.tex = 'C:/ctx/tex/texmf-mswin/bin/mtxrun --autogenerate --script context --autopdf --purge --synctex=-1 "%f"'* Note'''Important''': you have that your ConTeXt executables folder has to start `first-setup.bat` from the main ConTeXt directory every time you restart a machine, on which ConTeXt is not be in the Windows search path (see Step 1.3), otherwise you will get ''file not found''-errors, when trying to compile a ConTeXt document.* '''Note''' that you have to use slash <code>/</code> instead of backslash <code>\</code> in the file path, since Lua (same as ConTeXt) interprets a <code>\</code> as the beginning of a command.!
42.1.3. Restart Textadept to reload the modified <code>init.lua</code>.
42.1.4. Open or create a ConTeXt test document:
\starttext
hello world!
\stoptext
* You will have to save the file with an appropriate ending first, after that it will be recognized as ConTeXt format file automatically.
42.1.5. Use Textadept's '''Tools''' -> '''Compile''' to build a PDF with the options added to <code>init.lua</code>. A message buffer with compilation status will open in a seperate tab.
42.1.6. When you have a popular PDF reader installed already, it should pop up at the end of the process and show the created PDF output. [https://www.sumatrapdfreader.org/free-pdf-reader.html '''Sumatra PDF'''] is highly recommended for this.
=== Step 42.2: Lexing (command highlighting & code folding) ===
A lexer is a file that defines command highlighting and code folding keywords. Textadept comes with a ConTeXt lexer. In order to be able to use command highlighting and code folding when writing ConTeXt documents, you have to bind those documents to the lexer. To do so
42.2.1. add the following line to your <code>USER/.textadept/init.lua</code> and save it afterwards:
textadept.file_types.extensions.tex = 'context'
* If you plan to use LaTeX and ConTeXt, you might want to use different file extensions for each format. For example <code>*.tex</code> for LaTeX and <code>*.cxd</code> for ConTeXt documents. In that case you only have to bind your new ConTeXt extension to Textadept's ConTeXt lexer, since <code>.tex</code> files are automatically recognized as LaTeX documents:
textadept.file_types.extensions.cxd = 'context'
** When linking files within ConTeXt documents without adding an extension though, ConTeXt will expect those files to have the ending <code>*.tex</code>, i.e. you will have to work with filenames and extensions when using a format other than <code>*.tex</code>, which on the other hand should not be seen as a disadvantage. (TODO: which way is more "hack proof"?)
42.2.2. Restart Textadept to reload <code>init.lua</code>.
42.2.3. Open a ConTeXt document and check Textadept's status bar in the lower right corner. It should say '''context'''. If it says '''latex''' make sure it really is a ConTeXt file or repeat the procedure.
== Optional: Additional '''Textadept''' tweaks ==
You can change the theme, font and font size of Textadept with the following line
ui.set_theme('dark', {font = 'Monospace', fontsize = 10})
in which the expression '''dark''' is the filename of the theme located in either in <code>Textadept\themes</code> or you can download and add new themes to <code>USER\.textadept\themes</code>(after you created or downloaded and added them; create the folder if as itusually won's not t be there yet).
* Many ''base16'' themes for Textadept can be found at [https://github.com/rgieseke/textadept-themes Robert Gieseke's GitHub]. You can preview them [https://termux.com/add-on-styling-color-preview.html here] (partially).
=== Snippets ===
Snippets are predefined code or text blocks. Using snippets can save a lot of time as you won't have to retype often used commands and text passages. You add snippets to your <code>USER/.textadept/init.lua</code>. Alternatively you can cann create a new documentfile, e.g. <code>USER/.textadept/snippetsmysnippets.lua</code>, add all snippets to that file and load that file it from within your <code>init.lua</code> with the following line: require('snippetsmysnippets')
In Textadept snippets look like this:
snippets.context['TRIGGERKEYWORD'] = 'PASTEDTEXT'
snippets.context['ital'] = '{\\it %<selected_text>%0}' -- italic text/math
snippets.context['bold'] = '{\\bf %<selected_text>%0}' -- bold text/math
snippets.context['boldboldit'] = '{\\bi %<selected_text>%0}' -- bold italic text/math
snippets.context['start'] = '\\start%1\n\t%0\n\\stop%1'
snippets.context['itemize'] = '\\startitemize[packed]\n\t\\startitem\n\t\t%<selected_text>%0\n\t\\stopitem\n\\stopitemize' -- start itemization
** either by typing the keyword that you defined within <code>snippets.context['KEYWORD']</code> and pressing <code>Tab</code>-key afterwards
** or by using <code>Ctrl + K</code> (by default on Windows machines) to choose from the list of snippets. No matter in which order you add them to your <code>init.lua</code>, they will show up sorted alphabetically.
*** You can turn off alphabetical sorting of snippets by adding the following line to your <code>init.lua</code>:
 
TODO
 
* '''Note''' that since this way you bound snippets to Textadept's ConTeXt lexer, Textadept's status bar in the lower right corner has to say '''context''', otherwise use a ConTeXt document or see Step 4.2.
* Read more about snippets in Textadept's [https://foicica.com/textadept/api.html#textadept.snippets manual].
 
=3rd party projects=
194

edits

Navigation menu