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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
LEO(Log End Offset)是指副本底层log文件中下一条要写入的消息的位移。例如,如果LEO=10,那么当前文件已经写入了10条消息,位移范围是[0,10)。HW(High Watermark)是指所有分区已提交的位移,通常HW<=LEO。 对于多副本情况下,各个副本中的HW和LEO的演变过程如下:当Leader副本写入新的消息时,它会更新自己的LEO。Follower副本会从Leader副本中拉取消息,并更新自己的LEO为Leader副本的LEO值加1。同时,Follower副本还会更新自己的HW。更新HW的算法是比较当前LEO和Leader副本中传送过来的HW的值,然后取较小值作为自己的HW值。HW的更新会触发消费者端的位移提交和消息删除。 Kafka中的LEO和HW分别代表副本底层log文件中下一条要写入的消息的位移和所有分区已提交的位移。通过比较HW和消费者的位移,Kafka可以保证消息的顺序性。 关于分区器、序列化器和拦截器,分区器用于决定将消息发送到哪个分区,序列化器用于将消息对象序列化为字节流进行发送,拦截器则可以在消息发送前后进行一些处理。处理顺序是先经过拦截器,然后经过分区器和序列化器。 Kafka生产者客户端的整体结构包括一个或多个Producer线程、一个缓冲区、一个分区器、一个或多个拦截器和一个或多个序列化器。Producer线程负责将消息发送到Kafka集群中的Broker,缓冲区用于缓存待发送的消息,分区器决定消息被发送到哪个分区,序列化器将消息对象序列化为字节流进行发送,拦截器可以在消息发送前后进行一些处理。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值