LoginSignup
4
3

More than 5 years have passed since last update.

Atomエディタで本文1行目をタブに表示する方法

Posted at

StackOverflowで「 Atomエディタで本文1行目をタブに表示したい 」なる質問を見かけたので勉強がてらに作ってみた。

パッケージなどにはしていないので init.coffee に書くだけのお手軽仕様。

init.coffee
atom.workspace.observeTextEditors (editor) ->
  editor.onDidStopChanging =>
    elm = document.querySelector(".tab.sortable.active > .title")
    elm.innerHTML = editor.getText().split("\n")[0]

setTimeout ->
  items = []

  atom.workspace.getPanes().map (panel) ->
    panel.items.map (item) ->
      items.push item.buffer

  tabs = document.querySelectorAll(".tab.sortable > .title")
  for tab, i in tabs
    tab.innerHTML = items[i].cachedText.split("\n")[0] if items[i]
, 100

これで起動させた状態のタブ全部を書き換えてアクティブなタブも変更の度に書き換えるようには出来たものの、起動後に分割したPaneではなぜか書き換わらない。分割したイベントを拾って再登録してやらなきゃいけないのかな?

まあ、とりあえずこのくらいでもなんとかなるだろう。

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3