about summary refs log blame commit diff stats
path: root/html/mu-init.subx.html
blob: 8aa495313c51b1ca21495688e5733a4d7c7d8dad (plain) (tree)
1
2
3
4
5
6
7
8
9








                                                                                                               
                                                

                       

                                                                                                 




                                     
                             
                                  
































                                                                                 
                                                                                                                         


                                                                                                                         
                                                                                                                  
                                                                         



                                                                                                                                                            
                                       




                                                                                             























                                                                                                                                                                   



                                     
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Mu - mu-init.subx</title>
<meta name="Generator" content="Vim/8.1">
<meta name="plugin-version" content="vim8.1_v1">
<meta name="syntax" content="none">
<meta name="settings" content="number_lines,use_css,pre_wrap,no_foldcolumn,expand_tabs,line_ids,prevent_copy=">
<meta name="colorscheme" content="minimal-dark">
<style type="text/css">
<!--
pre { white-space: pre-wrap; font-family: monospace; color: #000000; background-color: #a8a8a8; }
body { font-size:12pt; font-family: monospace; color: #000000; background-color: #a8a8a8; }
a { color:inherit; }
* { font-size:12pt; font-size: 1em; }
.subxComment { color: #005faf; }
.LineNr { }
.SpecialChar { color: #d70000; }
.Constant { color: #008787; }
.CommentedCode { color: #8a8a8a; }
-->
</style>

<script type='text/javascript'>
<!--

/* function to open any folds containing a jumped-to line before jumping to it */
function JumpToLine()
{
  var lineNum;
  lineNum = window.location.hash;
  lineNum = lineNum.substr(1); /* strip off '#' */

  if (lineNum.indexOf('L') == -1) {
    lineNum = 'L'+lineNum;
  }
  var lineElem = document.getElementById(lineNum);
  /* Always jump to new location even if the line was hidden inside a fold, or
   * we corrected the raw number to a line ID.
   */
  if (lineElem) {
    lineElem.scrollIntoView(true);
  }
  return true;
}
if ('onhashchange' in window) {
  window.onhashchange = JumpToLine;
}

-->
</script>
</head>
<body onload='JumpToLine();'>
<a href='https://github.com/akkartik/mu/blob/main/mu-init.subx'>https://github.com/akkartik/mu/blob/main/mu-init.subx</a>
<pre id='vimCodeElement'>
<span id="L1" class="LineNr"> 1 </span><span class="subxComment"># Initialize the minimal runtime for Mu programs.</span>
<span id="L2" class="LineNr"> 2 </span><span class="subxComment">#</span>
<span id="L3" class="LineNr"> 3 </span><span class="subxComment"># See translate for how this file is used.</span>
<span id="L4" class="LineNr"> 4 </span><span class="subxComment">#</span>
<span id="L5" class="LineNr"> 5 </span><span class="subxComment"># Mu programs start at a function called 'main' with this signature:</span>
<span id="L6" class="LineNr"> 6 </span><span class="subxComment">#   fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk)</span>
<span id="L7" class="LineNr"> 7 </span><span class="subxComment">#</span>
<span id="L8" class="LineNr"> 8 </span><span class="subxComment"># All tests must pass first (the &quot;power-on unit test&quot;).</span>
<span id="L9" class="LineNr"> 9 </span>
<span id="L10" class="LineNr">10 </span>== code
<span id="L11" class="LineNr">11 </span>
<span id="L12" class="LineNr">12 </span><span class="SpecialChar">Entry</span>:
<span id="L13" class="LineNr">13 </span>  <span class="subxComment"># initialize stack</span>
<span id="L14" class="LineNr">14 </span>  bd/copy-to-ebp 0/imm32
<span id="L15" class="LineNr">15 </span>  <span class="subxComment"># Clear memory location 0 to ensure that uninitialized arrays run afoul of</span>
<span id="L16" class="LineNr">16 </span>  <span class="subxComment"># the bounds checker.</span>
<span id="L17" class="LineNr">17 </span>  <span class="subxComment"># TODO: This is utterly bonkers, and does not actually protect us against</span>
<span id="L18" class="LineNr">18 </span>  <span class="subxComment"># all null pointer reads/writes. Create a real page table sometime.</span>
<span id="L19" class="LineNr">19 </span>  b8/copy-to-eax 0/imm32
<span id="L20" class="LineNr">20 </span>  c7 0/subop/copy *eax 0/imm32
<span id="L21" class="LineNr">21 </span><span class="CommentedCode">#?   (main 0 0 Primary-bus-secondary-drive)</span>
<span id="L22" class="LineNr">22 </span>  <span class="subxComment"># always first run tests</span>
<span id="L23" class="LineNr">23 </span>  (run-tests)
<span id="L24" class="LineNr">24 </span>  (<a href='104test.subx.html#L17'>num-test-failures</a>)  <span class="subxComment"># =&gt; eax</span>
<span id="L25" class="LineNr">25 </span>  <span class="subxComment"># call main if tests all passed</span>
<span id="L26" class="LineNr">26 </span>  {
<span id="L27" class="LineNr">27 </span>    3d/compare-eax-and 0/imm32
<span id="L28" class="LineNr">28 </span>    75/jump-if-!= <span class="Constant">break</span>/disp8
<span id="L29" class="LineNr">29 </span>    (<a href='500fake-screen.mu.html#L364'>clear-real-screen</a>)
<span id="L30" class="LineNr">30 </span>    c7 0/subop/copy *<span class="SpecialChar"><a href='103grapheme.subx.html#L170'>Real-screen-cursor-x</a></span> 0/imm32
<span id="L31" class="LineNr">31 </span>    c7 0/subop/copy *<span class="SpecialChar"><a href='103grapheme.subx.html#L172'>Real-screen-cursor-y</a></span> 0/imm32
<span id="L32" class="LineNr">32 </span>    (main 0 0 <span class="SpecialChar"><a href='boot.subx.html#L899'>Primary-bus-secondary-drive</a></span>)
<span id="L33" class="LineNr">33 </span>  }
<span id="L34" class="LineNr">34 </span>
<span id="L35" class="LineNr">35 </span>  <span class="subxComment"># hang indefinitely</span>
<span id="L36" class="LineNr">36 </span>  {
<span id="L37" class="LineNr">37 </span>    eb/jump <span class="Constant">loop</span>/disp8
<span id="L38" class="LineNr">38 </span>  }
</pre>
</body>
</html>
<!-- vim: set foldmethod=manual : -->
indly, some keys might get lost. =item hidden_filter [regexp] A regular expression pattern for files which should be hidden. =item max_console_history_size [integer, None] How many console commands should be kept in history? =item max_history_size [integer, None] How many directory changes should be kept in history? =item mouse_enabled [bool] <zm> Enable mouse input? =item padding_right [bool] When collapse_preview is on and there is no preview, should there remain a little padding on the right? This allows you to click into that space to run the file. =item preview_directories [bool] <zP> Preview directories in the preview column? =item preview_files [bool] <zp> Preview files in the preview column? =item preview_script [string, None] Which script should handle generating previews? If the file doesn't exist, or use_preview_script is off, ranger will handle previews itself by just printing the content. =item save_console_history [bool] Should the console history be saved on exit? If disabled, the console history is reset when you restart ranger. =item scroll_offset [integer] Try to keep this much space between the top/bottom border when scrolling. =item shorten_title [integer, bool] Trim the title of the window if it gets long? The number defines how many directories are displayed at once, False turns off this feature. =item show_cursor [bool] Always show the terminal cursor? =item show_hidden_bookmarks [bool] Show dotfiles in the bookmark preview window? (Type ') =item show_hidden [bool] <zh>, <^H> Show hidden files? =item sort_case_insensitive [bool] <zc> Sort case-insensitively? If true, "a" will be listed before "B" even though its ASCII value is higher. =item sort_directories_first [bool] <zd> Sort directories first? =item sort_reverse [bool] <or> Sort reversed? =item sort [string] <oa>, <ob>, <oc>, <om>, <on>, <ot>, <os> Which sorting mechanism should be used? Choose one of B<atime>, B<basename>, B<ctime>, B<mtime>, B<natural>, B<type>, B<size> Note: You can reverse the order by using an uppercase O in the key combination. =item tilde_in_titlebar [bool] Abbreviate $HOME with ~ in the title bar (first line) of ranger? =item unicode_ellipsis [bool] Use a unicode "..." character instead of "~" to mark cut-off filenames? =item update_title [bool] Set a window title? =item use_preview_script [bool] <zv> Use the preview script defined in the setting I<preview_script>? =item xterm_alt_key [bool] Enable this if key combinations with the Alt Key don't work for you. (Especially on xterm) =back =head1 COMMANDS You can enter the commands in the console which is opened by pressing ":". There are additional commands which are directly translated to python functions, one for every method in the ranger.core.actions.Actions class. They are not documented here, since they are mostly for key bindings, not to be typed in by a user. Read the source if you are interested in them. =over 2 =item bulkrename This command opens a list of selected files in an external editor. After you edit and save the file, it will generate a shell script which does bulk renaming according to the changes you did in the file. This shell script is opened in an editor for you to review. After you close it, it will be executed. =item cd [I<directory>] The cd command changes the directory. The command C<:cd -> is equivalent to typing ``. =item chain I<command1>[; I<command2>[; I<command3>...]] Combines multiple commands into one, separated by columns. =item chmod I<octal_number> Sets the permissions of the selection to the octal number. The octal number is between 000 and 777. The digits specify the permissions for the user, the group and others. A 1 permits execution, a 2 permits writing, a 4 permits reading. Add those numbers to combine them. So a 7 permits everything. Key bindings in the form of [-+]<who><what> and =<octal> also exist. For example, B<+ar> allows reading for everyone, -ow forbids others to write and =777 allows everything. See also: man 1 chmod =item cmap I<key> I<command> Binds keys for the console. Works like the C<map> command. =item console [-pI<N>] I<command> Opens the console with the command already typed in. The cursor is placed at I<N>. =item copycmap I<key> I<newkey> [I<newkey2> ...] See C<copymap> =item copymap I<key> I<newkey> [I<newkey2> ...] Copies the keybinding I<key> to I<newkey> in the "browser" context. This is a deep copy, so if you change the new binding (or parts of it) later, the old one is not modified. To copy key bindings of the console, taskview, or pager use "copycmap", "copytmap" or "copypmap". =item copypmap I<key> I<newkey> [I<newkey2> ...] See C<copymap> =item copytmap I<key> I<newkey> [I<newkey2> ...] See C<copymap> =item cunmap I<key> I<command> Removes key mappings of the console. Works like the C<unmap> command. =item delete [I<confirmation>] Destroy all files in the selection with a roundhouse kick. ranger will ask for a confirmation if you attempt to delete multiple (marked) files or non-empty directories. When asking for confirmation, this command will only proceed if the last given word starts with a `y'. =item edit [I<filename>] Edit the current file or the file in the argument. =item eval [I<-q>] I<python_code> Evaluates the python code. `fm' is a reference to the FM instance. To display text, use the function `p'. The result is displayed on the screen unless you use the "-q" option. Examples: :eval fm :eval len(fm.env.directories) :eval p("Hello World!") =item filter [I<string>] Displays only the files which contain the I<string> in their basename. =item find I<pattern> Search files in the current directory that match the given (case-insensitive) regular expression pattern as you type. Once there is an unambiguous result, it will be run immediately. (Or entered, if it's a directory.) =item grep I<pattern> Looks for a string in all marked files or directories. =item load_copy_buffer Load the copy buffer from F<~/.config/ranger/copy_buffer>. This can be used to pass the list of copied files to another ranger instance. =item map I<key> I<command> Assign the key combination to the given command. Whenever you type the key/keys, the command will be executed. Additionally, if you use a quantifier when typing the key, like 5j, it will be passed to the command as the attribute "self.quantifier". The keys you bind with this command are accessible in the file browser only, not in the console, task view or pager. To bind keys there, use the commands "cmap", "tmap" or "pmap". =item mark I<pattern> Mark all files matching the regular expression pattern. =item mkdir I<dirname> Creates a directory with the name I<dirname>. =item open_with [I<application>] [I<flags>] [I<mode>] Open the selected files with the given application, unless it is omitted, in which case the default application is used. I<flags> are characters out of "sdpcwSDPCW" and I<mode> is any positive integer. Their meanings are discussed in their own sections. =item pmap I<key> I<command> Binds keys for the pager. Works like the C<map> command. =item punmap I<key> I<command> Removes key mappings of the pager. Works like the C<unmap> command. =item quit Like quit!, but closes only this tab if multiple tabs are open. =item quit! Quit ranger. The current directory will be bookmarked as ' so you can re-enter it by typing `` or '' the next time you start ranger. =item rename I<newname> Rename the current file. If a file with that name already exists, the renaming will fail. Also try the key binding A for appending something to a file name. =item save_copy_buffer Save the copy buffer from I<~/.config/ranger/copy_buffer>. This can be used to pass the list of copied files to another ranger instance. =item search I<pattern> Search files in the current directory that match the given (case insensitive) regular expression pattern. =item search_inc I<pattern> Search files in the current directory that match the given (case insensitive) regular expression pattern. This command gets you to matching files as you type. =item set I<option>=I<value> Assigns a new value to an option. Valid options are listed in the settings section. Use tab completion to get the current value of an option, though this doesn't work for functions and regular expressions. Valid values are: None None bool True or False integer 0 or 1 or -1 or 2 etc. list [1, 2, 3] tuple 1, 2, 3 or (1, 2, 3) function lambda <arguments>: <expression> regexp regexp('<pattern>') string Anything =item shell [-I<flags>] I<command> Run a shell command. I<flags> are discussed in their own section. =item terminal Spawns the I<x-terminal-emulator> starting in the current directory. =item touch I<filename> Creates an empty file with the name I<filename>, unless it already exists. =item tmap I<key> I<command> Binds keys for the taskview. Works like the C<map> command. =item tunmap I<key> I<command> Removes key mappings of the taskview. Works like the C<unmap> command. =item unmap [I<keys> ...] Removes the given key mappings in the "browser" context. To unmap key bindings in the console, taskview, or pager use "cunmap", "tunmap" or "punmap". =item unmark I<pattern> Unmark all files matching a regular expression pattern. =back =head1 FILES ranger reads several configuration files which are located in F<$HOME/.config/ranger> or F<$XDG_CONFIG_HOME/ranger> if $XDG_CONFIG_HOME is defined. The configuration is done mostly in python. When removing a configuration file, remove its compiled version too. (Python automatically compiles modules. Since python3 they are saved in the __pycache__ directory, earlier versions store them with the .pyc extension in the same directory.) Use the --copy-config option to obtain the default configuration files. They include further documentation and it's too much to put here. You don't need to copy the whole file though, most configuration files are overlaid on top of the defaults (F<options.py>, F<command.py>, F<rc.conf>) or can be sub-classed (F<apps.py>, F<colorschemes>). When starting ranger with the B<--clean> option, it will not access or create any of these files. =head2 CONFIGURATION =over 10 =item apps.py Controls which applications are used to open files. =item commands.py Defines commands which can be used by typing ":". =item rc.conf Contains a list of commands which are executed on startup. Mostly key bindings are defined here. =item options.py Sets a handful of basic options. =item scope.sh This is a script that handles file previews. When the options I<use_preview_script> and I<preview_files> or, respectively, I<preview_directories> are set, the program specified in the option I<preview_script> is run and its output and/or exit code determines rangers reaction. =item colorschemes/ Colorschemes can be placed here. =back =head2 STORAGE =over 10 =item bookmarks This file contains a list of bookmarks. The syntax is /^(.):(.*)$/. The first character is the bookmark key and the rest after the colon is the path to the file. In ranger, bookmarks can be set by typing m<key>, accessed by typing '<key> and deleted by typing um<key>. =item copy_buffer When running the command :save_copy_buffer, the paths of all currently copied files are saved in this file. You can later run :load_copy_buffer to copy the same files again, pass them to another ranger instance or process them in a script. =item history Contains a list of commands that have been previously typed in. =item tagged Contains a list of tagged files. The syntax is /^(.:)?(.*)$/ where the first letter is the optional name of the tag and the rest after the optional colon is the path to the file. In ranger, tags can be set by pressing t and removed with T. To assign a named tag, type "<tagname>. =back =head1 ENVIRONMENT These environment variables have an effect on ranger: =over 8 =item EDITOR Defines the editor to be used for the "E" key. Defaults to the first installed program out of "vim", "emacs" and "nano". =item SHELL Defines the shell that ranger is going to use with the :shell command and the "S" key. Defaults to "bash". =item XDG_CONFIG_HOME Specifies the directory for configuration files. Defaults to F<$HOME/.config>. =item PYTHONOPTIMIZE This variable determines the optimize level of python. Using PYTHONOPTIMIZE=1 (like python -O) will make python discard assertion statements. You will gain efficiency at the cost of losing some debug info. Using PYTHONOPTIMIZE=2 (like python -OO) will additionally discard any docstrings. Using this will disable the <F1> key on commands. =back =head1 EXAMPLES =head2 VIM: File Chooser This is a vim function which allows you to use ranger to select a file for opening in your current vim session. fun! RangerChooser() silent !ranger --choosefile=/tmp/chosenfile `[ -z '%' ] && echo -n . || dirname %` if filereadable('/tmp/chosenfile') exec 'edit ' . system('cat /tmp/chosenfile') call system('rm /tmp/chosenfile') endif redraw! endfun map ,r :call RangerChooser()<CR> =head2 Bash: cd to last path after exit This is a bash function (for F<~/.bashrc>) to change the directory to the last visited one after ranger quits. You can always type C<cd -> to go back to the original one. function ranger-cd { tempfile='/tmp/chosendir' /usr/bin/ranger --choosedir="$tempfile" "${@:-$(pwd)}" test -f "$tempfile" && if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then cd -- "$(cat "$tempfile")" fi rm -f -- "$tempfile" } # This binds Ctrl-O to ranger-cd: bind '"\C-o":"ranger-cd\C-m"' =head1 LICENSE GNU General Public License 3 or (at your option) any later version. =head1 LINKS =over =item Download: L<http://ranger.nongnu.org/ranger-stable.tar.gz> =item The project page: L<http://ranger.nongnu.org/> =item The mailing list: L<http://savannah.nongnu.org/mail/?group=ranger> =back ranger is maintained with the git version control system. To fetch a fresh copy, run: git clone git://git.savannah.nongnu.org/ranger.git =head1 BUGS Report bugs here: L<http://savannah.nongnu.org/bugs/?group=ranger> Please include as much relevant information as possible. For the most diagnostic output, run ranger like this: C<PYTHONOPTIMIZE= ranger --debug>