Changes

Jump to navigation Jump to search
2,818 bytes added ,  08:00, 10 August 2018
Added a line of code for the new method of switching themes in TA10.
[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].
=3rd party projectsConTeXt with Textadept (MS Windows) =(updated 2017/12) == Step 1: Install '''Textadept''' ==
A ConTeXt module for 1.1. [https://foicica.com/textadept is being developed at /download/textadept_LATEST.win32.zip Download] and extract [https://githubfoicica.com/stephengaitotextadept/ta-context-latex ta-context-latex'''Textadept''']to a folder of your choice.
Note though, that if you plan to use Textadept without LaTeX with ConTeXt mkiv only (recommended), then you might not need 1.2. Use <code>textadept.exe</code> from the package mentioned above as it comes with literally only a hand full of ConTeXt snippets. It's almost more comfortable extracted folder to create own ConTeXt snippets with the ease of start Textadept (see below).
= How to ConTeXt with = Step 2: Tweak '''Textadept (updated 2017/03) ''''s settings ==
== Step 1: Install '''ConTeXtNote''' ==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:
work * One of them is in progressthe extracted Textadept main folder. It is '''not recommended''' to edit this file as your changes will be lost when you update Textadept. Instead:* When you start Textadept for the first time, a new folder <code>SYSDRIVE:\users\USERNAME\.textadept</code> gets created. It also contains a file called <code>init.lua</code>. This is the file and location where you should save all your Textadept settings. This way you can make a copy and use it on several computers. When you open it for the first time it should be empty.
== Step 2Usually you have to restart Textadept after changing its configuration files. Robert Gieseke created a code though, which you can add to your <code>init.lua</code> to circumvent having to restart Textadept whenever a change is made: Add ConTeXt's executables folder to Windows search PATH ==
work in progress -- Save and reset Lua state: `F9` keys['f9'] = function() -- Mac OSX users might prefer: keys[OSX and 'mf9' or 'f9'] io.save_file() reset() end
== Step 3: Install ''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''' ==.
# [https://foicica.com/textadept/download/textadept_LATEST.win32=== Step 2.zip Download] and extract [https1://foicica.com/textadept/ '''Textadept'''] to Bind a folder of your choice.# Use <code>textadept.exe</code> from the extracted folder to start '''PDF build command into Textadept'''.===
== Step 42.1.1. Use Textadept to open your <code>init.lua</code> stored in <code>SYSDRIVE: Tweak '''Textadept''''s settings ==\users\USER\.textadept\</code>.
2.1. Use your freshly installed Textadept to open Textadept's main configuration file called <code>init.lua</code>.* After extraction of the downloaded Textadept archive there is a file called <code>init.lua</code> in the main program folder. It is '''not recommended''' to edit this file as your changes will be lost when you update Textadept. Instead:* When you start Textadept for the first time a new folder <code>SYSDRIVE:\users\USERNAME\.textadept</code> gets created. It also contains the file called <code>init.lua</code>. It's the file and location where you should save all your Textadept settings. This way you can make a copy and use it on several computers. When you open it for the first time it should be empty.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 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''' that you have your ConTeXt executables folder has to use slash <code>/</code> instead of backslash <code>\</code> be in the file Windows search path, since Lua (same as ConTeXt) interprets a <code>\</code> as the beginning of a command, while for Windows it doesn't make any difference.3. Restart Textadept to reload the modified <code>init.lua</code>.!
2.1.3. Restart Textadept to reload the modified <code>init.lua</code>. 2.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.
2.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.
2.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.
== Optional= Step 2.2: Additional '''Textadept''' tweaks Lexing (command highlighting & code folding) ===
=== Lexing ===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
Textadept comes with an own ConTeXt lexer2.2.1. add the following line to your <code>USER/. A lexer is a file that defines command highlightingtextadept/init. So lua</code> and save itafterwards: textadept.file_types.extensions.tex = 's a good idea context'* If you plan to use LaTeX and ConTeXt, you might want to bind use different file extensions for each format. For example <code>*.tex</code> for LaTeX and/or <code>*.ctxcxd</code> files for ConTeXt documents. In that case you only have to bind your new ConTeXt extension to Textadept's ConTeXt lexer, since <code>. To do sotex</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.
12.2.2. Add the following lines Restart Textadept to your reload <code>USER/.textadept/init.lua</code>:. textadept2.file_types2.extensions3.tex = 'context'* If you plan to use LaTeX and Open a ConTeXt, you should use different file extensions. For example <code>*.tex</code> for LaTeX document and <code>*.ctx</code> for ConTeXt documents. In that case you only have to bind your new ConTeXt extension to check Textadept's ConTeXt lexer, since <code>status bar in the lower right corner.tex</code> files are automatically recognized as LaTeX documents: textadept.file_types.extensions.ctx = It should say '''context'2''. Restart Textadept to reload <code>initIf it says '''latex''' make sure it really is a ConTeXt file or repeat the procedure.lua</code>
3. Open a ConTeXt document and check Textadept== Optional: Additional 's status bar in the lower right corner. It should say '''context'''. If it says '''latexTextadept''' make sure it really is a ConTeXt file or repeat the procedure.tweaks ==
=== Themes & editor font changes ===
* You can change the theme, font and font size of Textadept with the following line ui.set_theme('dark', {font = 'Monospace', fontsize = 10}) -- Textadept v9 buffer:set_theme('dark', {font = 'Monospace', fontsize = 10}) -- Textadept v10in 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). * There are more settings which you can look up in Textadept's [https://foicica.com/textadept/manual.html#Themes online manual].
=== 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 them, again, snippets to your <code>USER/.textadept/init.lua</code>. Snippets in In Textadept snippets look like this: snippets.context['TRIGGERKEYWORD'] = 'PASTEDTEXT' To get an idea how writing snippets (for ConTeXt) works, you can copy and paste the following list to your <code>init.lua</code>:
-- The first line is mandatory:
snippets['context'] = snippets['context'] or {}
-- Snippets start here: snippets.context['emph'] = '{\\em %<selected_text>%0}' -- emphasized text/math snippets.context['ital'] = '{\\it %<selected_text>%0}'-- italic text/math snippets.context['bold'] = '{\\bf %<selected_text>%0}' -- bold text/math snippets.context['boldit'] = '{\\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 snippets.context['item'] = '\\startitem\n\t%<selected_text>%0\n\\stopitem'
snippets.context['enumerate'] = '\\startenumerate\n\t%0\n\\stopenumerate'
snippets.context['chapter'] = '\\startchapter[title={%1},marking{%1}]\n\t%0\n\\stopchapter' snippets.context['section'] = '\\startsection[title={%1},marking{%1}]\n\t%0\n\\stopsection' snippets.context['ssection'] = '\\startsubsection[title={%1},marking{%1}]\n\t%0\n\\stopsubsection' snippets.context['title'] = '\\starttitle[title={%1},marking{%1}]\n\t%0\n\\stoptitle' snippets.context['subject'] = '\\startsubject[title={%1},marking{%1}]\n\t%0\n\\stopsubject' snippets.context['ssubject'] = '\\startsubsubject[title={%1},marking{%1}]\n\t%0\n\\stopsubsubject'
* '''Note''' that a backslash is created as you would type it in ConTeXt: typing a double backslash <code>\\</code> prints is set by typing a single double backslash <code>\\</code>.
* The most important formatting commands are the following:
**<code>\n</code> set a line break (new line)**<code>\t</code> set a tabulated**<code>%0</code> creates a primary or a single input set the ''closing'' caret(placeholder) (the cursor will jump here '''last''')**<code>%1</code> creates a secondary set one or multiple input caretcarets (<code>%1</code>, <code>%2</code>, <code>%3</code> and so on; you can also use the same integer multiple times: e.g. <code>\\start%1 ... \\stop%1</code>)**<code>%n<selected_text></code> creates this is where highlighted text will be pasted when enclosing it with a new linesnippet (e.g. <code>{\\bi %<selected_text>%0}</code>) * After adding snippets, you have to restart Textadept or reset Lua state as described in Step 2. * You can paste snippets into ConTeXt documents** 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>%tCtrl + 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> creates , they will show up sorted alphabetically.* '''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 tabConTeXt document or see Step 2.2. * Read more about snippets in Textadept's [https://foicica.com/textadept/api.html#textadept.snippets manual]. =3rd party projects= A ConTeXt module for Textadept is being developed at [https://github.com/stephengaito/ta-context-latex ta-context-latex].
* After you added snippetsNote though, that if you have plan to restart use Textadept first.* Then you can use <code>Alt + K</code> without LaTeX with ConTeXt mkiv only (by default on Windows machinesrecommended) to choose from , then you might not need the list package mentioned above as it comes with literally only a hand full of ConTeXt snippets. It also needs additional software to be installed (Textredux, ctags), when a so that it's almost more comfortable to create own ConTeXt documents is opensnippets with the ease of Textadept (see above).
194

edits

Navigation menu