• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript atom.TextEditor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中atom.TextEditor的典型用法代码示例。如果您正苦于以下问题:TypeScript TextEditor类的具体用法?TypeScript TextEditor怎么用?TypeScript TextEditor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TextEditor类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: insertResult

  function insertResult(i: number, editor: TextEditor, lines: string[]) {
    const lineCount = editor.getLineCount();
    let start = 0;
    // find <!- code_chunk_output -->
    for (let j = i + 1; j < i + 6 && j < lineCount; j++) {
      if (lines[j].startsWith("<!-- code_chunk_output -->")) {
        start = j;
        break;
      }
    }

    if (start) {
      // found
      // TODO: modify exited output
      let end = start + 1;
      while (end < lineCount) {
        if (lines[end].startsWith("<!-- /code_chunk_output -->")) {
          break;
        }
        end += 1;
      }

      // if output not changed, then no need to modify editor buffer
      let r = "";
      for (let i2 = start + 2; i2 < end - 1; i2++) {
        r += lines[i2] + "\n";
      }
      if (r === result + "\n") {
        return "";
      } // no need to modify output
      editor
        .getBuffer()
        .setTextInRange([[start + 2, 0], [end - 1, 0]], result + "\n");
      /*
      editor.edit((edit)=> {
        edit.replace(new vscode.Range(
          new vscode.Position(start + 2, 0),
          new vscode.Position(end-1, 0)
        ), result+'\n')
      })
      */
      return "";
    } else {
      editor
        .getBuffer()
        .insert(
          [i + 1, 0],
          `<!-- code_chunk_output -->\n\n${result}\n\n<!-- /code_chunk_output -->\n`,
        );
      return "";
    }
  }
开发者ID:bitst0rm-dev,项目名称:markdown-preview-enhanced,代码行数:52,代码来源:extension.ts


示例2: getSymbolAtPoint

export function getSymbolAtPoint(
  editor: TextEditor, point: Point,
) {
  const [scope] = editor.scopeDescriptorForBufferPosition(point).getScopesArray().slice(-1)
  if (scope) {
    const range = editor.bufferRangeForScopeAtPosition(scope, point)
    if (range && !range.isEmpty()) {
      const symbol = editor.getTextInBufferRange(range)
      return { scope, range, symbol }
    }
  }
  return undefined
}
开发者ID:mvoidex,项目名称:atom-haskell-hsdev,代码行数:13,代码来源:util.ts


示例3: deserializeEditorState

export function deserializeEditorState(
  editor: TextEditor,
  {bufferRanges, scrollTop}: ReturnType<typeof serializeEditorState>,
) {
  const editorElement = atom.views.getView(editor)
  editor.setSelectedBufferRanges(bufferRanges)
  editorElement.setScrollTop(scrollTop)
}
开发者ID:TypeStrong,项目名称:atom-typescript,代码行数:8,代码来源:utils.ts


示例4: constructor

 constructor(public props: Props) {
   this.model = atom.workspace.buildTextEditor({
     mini: true,
     softWrapped: true,
     lineNumberGutterVisible: false,
   })
   this.element = atom.views.getView(this.model)
   this.model.setText(props.initialText)
   if (props.selectAll) {
     this.model.selectAll()
   } else {
     this.model.getLastCursor().moveToEndOfScreenLine()
   }
   this.setReadOnly()
   this.setGrammar()
   this.model.scrollToBufferPosition([0, 0])
 }
开发者ID:TypeStrong,项目名称:atom-typescript,代码行数:17,代码来源:miniEditor.ts


示例5: serializeEditorState

export function serializeEditorState(editor: TextEditor) {
  const editorElement = atom.views.getView(editor)
  const scrollTop = editorElement.getScrollTop()

  return {
    bufferRanges: editor.getSelectedBufferRanges(),
    scrollTop,
  }
}
开发者ID:TypeStrong,项目名称:atom-typescript,代码行数:9,代码来源:utils.ts


示例6: getSymbolInRange

export function getSymbolInRange(editor: TextEditor, crange: Range) {
  const buffer = editor.getBuffer()
  if (crange.isEmpty()) {
    return getSymbolAtPoint(editor, crange.start)
  } else {
    return {
      symbol: buffer.getTextInRange(crange),
      range: crange,
    }
  }
}
开发者ID:mvoidex,项目名称:atom-haskell-hsdev,代码行数:11,代码来源:util.ts


示例7: bufferPositionFromMouseEvent

export function bufferPositionFromMouseEvent(
  editor: TextEditor,
  event: MouseEvent,
) {
  const sp: Point = (atom.views.getView(
    editor,
  ) as any).component.screenPositionForMouseEvent(event)
  if (isNaN(sp.row) || isNaN(sp.column)) {
    return undefined
  }
  return editor.bufferPositionForScreenPosition(sp)
}
开发者ID:atom-haskell,项目名称:ide-haskell,代码行数:12,代码来源:index.ts


示例8: bufferPositionFromMouseEvent

export function bufferPositionFromMouseEvent(
  editor: TextEditor,
  event: {clientX: number; clientY: number},
) {
  const sp = atom.views
    .getView(editor)
    .getComponent()
    .screenPositionForMouseEvent(event)
  if (isNaN(sp.row) || isNaN(sp.column)) {
    return
  }
  return editor.bufferPositionForScreenPosition(sp)
}
开发者ID:TypeStrong,项目名称:atom-typescript,代码行数:13,代码来源:util.ts


示例9: constructor

 constructor(private editor: TextEditor, groups: IMarkerGroup[]) {
   // tslint:disable-next-line:no-null-keyword
   this.table = Object.create(null)
   for (const i of eventRangeTypeVals) {
     this.table[i] = new Map()
   }
   this.layers = new Set()
   for (const i of groups) {
     const layer = this.editor.addMarkerLayer()
     this.layers.add(layer)
     for (const { type, source } of i) {
       ;(this.table[type] as TTableCell).set(source, layer)
     }
   }
 }
开发者ID:atom-haskell,项目名称:ide-haskell,代码行数:15,代码来源:event-table.ts


示例10: editorFormat

 function editorFormat(input: string) {
   editor.setText(input)
   if (opts.selectBeforeTest) {
     editor.setSelectedBufferRange(editor.getBuffer().getRange())
   }
   atom.commands.dispatch(
     atom.views.getView(editor),
     'markdown-table-formatter:format',
   )
   return editor.getText()
 }
开发者ID:fcrespo82,项目名称:atom-markdown-table-formatter,代码行数:11,代码来源:editor.spec.ts



注:本文中的atom.TextEditor类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript atom-plugin-command-line.default函数代码示例发布时间:2022-05-25
下一篇:
TypeScript atom.TextBuffer类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap