leo學習系列之三——leo基礎用法算子

1:改變佈局

  • 通過菜單命令:"Window/Toggle Split Direction" 設置

2:@file 標籤(算子):輸出文件

  • 位置:節點中
  • @file節點必須包含@others(如果有子節點),否則會報錯!刪除子節點之後,子節點不存在父節點的@file文件中,但是子節點的@nosent會包含在父節點的@file中
  • @file 下的@nosent不輸出文件
  • 在Leo 載入時,自動的將 @file 指示的文件,從外部文件更新入Leo 文件了,在Leo 中進行了編輯保存時,也會自動更新外部文件

3:@ignore

  • 保存時,不改變外部文件。此項一般要去除。

4:@others @all

  • 在使用 @file 標籤後,

  • 可以簡單的使用 @others標籤來包含當前結點以下的所有結點

  • 象XSL 中的<xsl:for-each select="//."> 哈哈哈

  • Copies the body text of all nodes except section definition nodes in an @file tree to the corresponding external file.

對比:相同點@other不包括<<>>,@all 包括<<>>  ----在@nosent和@file中用法相同

These control how Leo places text when writing external files. They are two of the most important directives in Leo.

@all

Copies all descendant nodes to the external file. Use @all to place unrelated data in an external file.

The @all directive is valid only in the body of @file trees.

Within the range of an @all directive, Leo ignores the @others directive and section references, so Leo will not complain about orphan nodes.

@others

Writes the body text of all unnamed descendant into the external file, in outline order.

Whitespace appearing before @others directive adds to the indentation of all nodes added by the @others directive.

A single node may contain only one @others directive, but descendant nodes may have other @others directives.


5:自動導入

  • Leo 的 File/Import.../Import To @file 命令,支持對 C/C++/C#;Java;Python;Perl...語言的自動分析文章化組織的導入

  • 不過,自動生成的文本中可能有一些標籤:
    • {{{@ignore

@language python }}}

  • 是不屬於 @file 管理範圍的,

  • 只要簡單的註釋掉,就可以成爲標準的,可以自動同步外部文件的文本結點對象了

6:<<section>>

  • 在 @root限定處理下,各子結點的引用,與包含處理是使用 <<章節>> 標記

7:Tangle & Untangle

  • 這時,針對外部文件的同步,需要人工操作
    • 菜單命令:"File/Tangle.../Tangle" - 混出

    • 菜單命令:"File/Untangle.../Untangle" - 混入

    • 是一對相應的操作
      • Tangle 是將當前的編輯混出到外部文件中
      • Untangle 反之

8:@thin

大多數情況中 @thin 如同 @file 一樣的工作. 實際上,你可以簡單的將 @file 替換爲 @thin 進行正常的 outline 操作.

這裏是主要幾點 @file 與 @thin 不同之處:

  • Leo 不會在 .leo 文件的 @thin 節點樹中保存信息
  • 源自 @thin 的文件 (可以稱作 "輕依賴"文件) 是從文件的outline 信息重建 @thin 樹的. 具體的就是利用文本中 @+node 和 @-node 作爲獨特的標識節點
  • . @all 指示符僅僅在 @thin 樹中起作用. 此指示符與 @others 類似, 不過對其有些限制:(haoxiangbudui)
    • 它將倒出所有標記以內的節點到文件中,包括標記爲 @ignore 和 @others 以下的樹會當作普通的孤立節點倒出. (不妙的體驗是,原先 @others 可以限定下屬節點倒出文本時的縮進,而@all 粗暴的將所有下級節點當作同級的兄弟處理了!)

9:@root vs. @file 樹

@file 樹比 @root 樹使用起來方便很多:

  1. @file 樹需要的指示符支持比 @root 樹要少; 所有 @root 樹中的章節都需要聲明(而且不能重名,在同一文件中!), 而 @file 樹常常包含很多非命名的章節節點. 在 @file 樹中, @others 指示符 行爲就象關聯起所有非常命名的章節.
  2. 工作在 @root 樹中,用戶必須明確調用 Tangle 和 Untangle 命令. 而 Leo 會自動混入/出 @file 樹 , 保存時混出所有變動到 outline, 重新打開 .loe 文件時自動混入所有修改從 outline.

但是, @root 樹比 @file 樹要 柔韌很多:

  1. 在 @file 樹中, 章節必須是包含在子節點中的,而且引用點也是固定的.
  2. 在 @root 樹中一個被聲明的章節, 並不限制其可以在哪裏被引用. 此外,@unit 指示符命令甚至於擴展了章節的引用, 可以不限制在一個 @root 樹中! 即,你可以在一個 @root 中命名一個章節, 而在另一個 @root 樹中引用(可以看作 節點的 clone 操作,只是在引用處看不到全部內容,除非混出爲文件)
  3. 在 @root 中的章節聲明,也不限制聲明的地點.

@root 樹與 @file 樹不同之處在於:

  1. 只有 @root 樹可以包含章節定義行(不過 @file 中可以使用 "<< class declarations >>"類聲明的專用章節)

  2. 只有 @file 樹可以包含 @others 指示符.
  3. @c 指示符 需要章節名出現在 @root 的節點標題樹中.
  4. @c 指示符僅僅可以工作在 @file 樹的體文本起始處.所謂 體文本是在 @root 中沒有標記會被忽略,而在 @file 樹是作爲無命名的代碼章節內容處理的節點正文文本.



The following table summarizes the various ways of creating external files.

Kind Sentinels in external file? Sections and @others expanded on write? File data stored in .leo file?
@asis no no yes
@auto no yes no
@edit no no no
@nosent no yes yes
@shadow Note 1 yes no
@file @thin Note 2 yes yes no

Note 1: @shadow nodes create two files, a public file without sentinels and a private file with sentinels.

Note 2: @file and @thin nodes are synonyms.

  • 經體驗, 可以簡單的使用 @nosent 替換 @root ,可以象 @file 一樣的使用,卻又沒有Python格式的註釋的結構信息
    • 而且,@others 章節聲明也可以很好的混同使用
    • 只是不能象 @root 那樣在正文中使用@root expfile.t2t 模式的聲明,而必須在 outline 樹節點中顯要的指明

    • 如此就可以使用 Leo 方便的管理,編輯不支持 # 爲註釋的各種語言文件了

    • 嗯嗯 ? 只是可惜的是這樣一來,所有代碼只能安全的存儲在 .leo 文件中,生成的代碼文件是乾淨了,但是團隊開發時,就要反覆同步 .leo 文件,否則,難以快速把握哪些文件受到修改了…………

10:@asis <path>

The @@ convention: Within @asis trees only, if a headline starts with @@, Leo writes everything in the headline following the @@ just before the corresponding body text.

解釋;在@asis中,他的子節點以@@開頭的話,那麼@@後面的內容以及@@節點的內容都將被寫進@asis文件中

@button

做測試用
  • You can bind keys to the commands created by script buttons:

    @button my-button @key=Alt-8
在正文中寫
g.es('Hello World!')
g.es('from fuwenchao!')


點擊上面的my-button按鈕,會在log pane中打印hello world,from fuwenchao
具體參加:
http://leoeditor.com/tutorial-scripting.html#index-8
http://leoeditor.com/unitTesting.html



@color

Enables syntax coloring until the next @nocolor directive.

@killcolor

Disables syntax coloring in a node, overriding all @color, @nocolor or @nocolor-node directives in the same node.

@nocolor

Disables syntax coloring until the next @nocolor directive.

@nocolor-node

Disables coloring for only the node containing it. The @nocolor-node directive overrides the @color and @nocolor directives within the same node.

@ and @doc

These directives start a doc part. @doc is a synonym for @. Doc parts continue until an @c directive or the end of the body text. For example:

@ This is a comment in a doc part.
Doc parts can span multiple lines.
The next line ends the doc part
@c

When writing external files, Leo writes doc parts as comments.

Leo does not recognize @ or @doc in @asis trees or when the @all or @delims directives are in effect.

@c and @code

Ends any doc part and starts a code part.

@code is a deprecated synonym for @c.

Leo does not recognize this directive in @asis trees or when the @all or @raw directives are

@encoding <encoding>

Specifies the Unicode encoding for an external file. For example:

@encoding iso-8859-1

When reading external files, the encoding given must match the encoding actually used in the external file or “byte hash” will result.

@first <text>

Places lines at the very start of an external file, before any Leo sentinels. @first lines must be the very first lines in an @<file> node. More then one @first lines may appear.

This creates two first lines, a shebang line and a Python encoding line:

@first #! /usr/bin/env python
@first # -*- coding: utf-8 -*-

Here is a perl example:

@first #!/bin/sh -- # perl, to stop looping
@first eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
@first     if 0;

@last <text>

Places lines at the very end of external files.

This directive must occur at the very end of top-level @<file> nodes. More than one @last directive may exist. For example:

@first <?php
...
@last ?>

Leo does not recognize @last directive in @asis trees.


@ignore 忽略節點

Tells Leo to ignore the subtree in which it appears.

In the body text of most top-level @<file> nodes, the @ignore directive causes Leo not to write the tree. However, Leo ignores @ignore directives in @asis trees.

Plugins and other parts of Leo sometimes @ignore for their own purposes. For example, Leo’s unit testing commands will ignore trees containing @ignore. In such cases, the @ignore directive may appear in the headline or body text.

   @edit <path>

   The @edit directive imports an external file into a single node.

When reading @edit nodes, Leo reads the entire file into the @edit node. Lines that look like sentinels will be read just as they are.

When writing @edit nodes, @edit nodes must not have children and section references and @others are not allowed.


@shadow <path>

The @shadow directive creates two external files, a public file without sentinels, and a private file containing sentinels.

When reading an @shadow node, Leo uses a brilliant algorithm devised by Bernhard Mulder that compares the public and private files, and then updates the outline based on changes to the public file. In this way, @shadow provides many of the benefits of @file trees without writing sentinels in the (public) external file.

Leo can do an initial import of @shadow trees by parsing the corresponding public file, exactly as is done for @auto nodes.




@pagewidth <n>

Sets the page width used to break doc parts into lines. <n> should be a positive integer. For example:

@pagewidth 100

The @pagewidth directive overrides the @int page_width setting.


@tabwidth <n>

Sets the width of tabs. Negative tab widths cause Leo to convert tabs to spaces.

@int page_width=60  節點上

@string target_language=rest 節點上

@language <language name>

Specifies the language in effect, including comment delimiters. If no @language directive is in effect, Leo uses the defaults specified by the @string target-language setting.

A node may contain at most one @language directive.

The valid language names are: actionscript, ada, autohotkey, batch, c, config, cpp, csharp, css, cweb, elisp, forth, fortran, fortran90, haskell, haxe, html, ini, java, javascript, kshell, latex, lua, noweb, pascal, perl, perlpod, php, plain, plsql, python, rapidq, rebol, rest, rst, ruby, shell, tcltk, tex, unknown, unknown_language, vim, vimoutline, xml, xslt.

Note: Shell files have comments that start with #.

Case is ignored in the language names. For example, the following are equivalent:

@language html
@language HTML

The @language directive also controls syntax coloring. For language x, the file leo/modes/x.py describes how to colorize the language. To see the languages presently supported, look in the leo/modes directory. There are over 100 such languages.

@lineending cr/lf/nl/crlf

Sets the line endings for external files. This directive overrides the @string output_newline setting.

The valid forms of the @lineending directive are:

@lineending nl The default, Linux.
@lineending cr Mac
@lineending crlf Windows
@lineending lf Same as ‘nl’, not recommended
@lineending platform Same as platform value for output_newline setting.

@path <path>

Sets the path prefix for relative filenames for all @<file> tree.(@nosent也管用呀)

This directive may appear in headlines or body text, and may appear in top-level @<file> nodes.

The path is an absolute path if it begins with c:\ or /, otherwise the path is a relative paths.

Multiple @path directives may contribute to the path prefix. Absolute paths overrides any ancestor @path directives. Relative paths add to the path prefix.

If no @path directives are in effect, the default path prefix is the directory containing the .leo file.

Within @path and @<file> paths, {{exp}} gets evaluated with the following symbols known: c, g, p, os and sys. For example:

@file {{os.path.abspath(os.curdir)}}/abc.py

refers to the file abc.py in (absolute path of) the current directory.

@wrap

Enables line wrapping in Leo’s body pane.

Only the first @wrap or @nowrap directive in a node has any effect.

@wrap may appear in either headlines or body text.

@nowrap

Disables line wrapping the Leo’s body pane.

Only the first @wrap or @nowrap directive in a node has any effect.

@nowrap may appear in either headlines or body text.

@raw and @end_raw

@raw starts a section of “raw” text that ends only with the @end_raw directive or the end of the body text containing the @raw directive. Within this range, Leo ignores all section references and directives, and Leo generates no additional leading whitespace.



更多請閱讀:http://leoeditor.com/directives.html
http://leoeditor.com/glossary.html#index-1

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章