Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Goで作るインタラクティブなCLIコマンドとそのデザイン

 Goで作るインタラクティブなCLIコマンドとそのデザイン

Golang.Tokyo #18 発表資料

Toshikazu Ohashi

September 28, 2018
Tweet

More Decks by Toshikazu Ohashi

Other Decks in Programming

Transcript

  1. UJH

  2. ඳը • όοΫόοϑΝʹඳը͢ΔจࣈྻΛඳը͍ͯ͘͠ • func SetCell(x, y int, ch rune,

    fg, bg Attribute) • όοΫόοϑΝΛεΫϦʔϯʹ൓ө • func Flush() error
  3. termbox.SetCell(3, 1, 'a', termbox.ColorRed, ...) termbox.SetCell(6, 3, 'b', termbox.ColorBlue, ...)

    termbox.SetCell(9, 5, 'c', termbox.ColorGreen, ...) όοΫόοϑΝ aaaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaa aaaaaabaaaa aaaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaa aaaaaabaaaa aaaaaaaaaaa aaaaaaaaaca aaaaaaaaaaa
  4. Flush() όοΫόοϑΝ εΫϦʔϯ aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaa aaaaaabaaaaaaaaaaa aaaaaaaaaaaaaaaaaa aaaaaaaaacaaaaaaaa aaaaaaaaaaaaaaaaaa

    aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaa aaaaaabaaaaaaaaaaa aaaaaaaaaaaaaaaaaa aaaaaaaaacaaaaaaaa aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaa
  5. จࣈྻඳը func tbPrint(x, y int, fg, bg termbox.Attribute, msg string)

    { for _, c := range msg { termbox.SetCell(x, y, c, fg, bg) x++ } }
  6. 1 # Contributing to Go⊠ 2 ⊠ 3 Go is

    an open source project.⊠ 4 ⊠ 5 It is the work of hundreds of contributors...⊠ 6 ⊠ 7 ## Before filing an issue⊠ 8 ⊠ 9 If you are unsure whether you have found...⊠ 10 https://groups.google.com/forum/#!forum/...⊠ 11 the behavior you are seeing is confirmed...⊠ 12 ⊠ 13 ## Filing issues⊠ 14 ⊠ 15 Sensitive security-related issues should...⊠ 16 See the [security policy](https://golang...⊠ 17 ⊠ 18 The recommended way to file an issue is ...⊠ 19 Otherwise, when filing an issue, make...⊠ 20 ⊠ ίϯςϯπͷߴ͞ (20) ΧʔιϧҐஔ(17) ඳըҐஔ(3) ඳըྖҬͷߴ͞ (14) εΫϩʔϧ
  7. 1 # Contributing to Go⊠ 2 ⊠ 3 Go is

    an open source project.⊠ 4 ⊠ 5 It is the work of hundreds of contributors...⊠ 6 ⊠ 7 ## Before filing an issue⊠ 8 ⊠ 9 If you are unsure whether you have found...⊠ 10 https://groups.google.com/forum/#!forum/...⊠ 11 the behavior you are seeing is confirmed...⊠ 12 ⊠ 13 ## Filing issues⊠ 14 ⊠ 15 Sensitive security-related issues should...⊠ 16 See the [security policy](https://golang...⊠ 17 ⊠ 18 The recommended way to file an issue is ...⊠ 19 Otherwise, when filing an issue, make...⊠ 20 ⊠ ΧʔιϧҐஔ(19) ίϯςϯπͷߴ͞ (20) ඳըྖҬͷߴ͞ (14) ඳըҐஔ(3)
  8. 1 # Contributing to Go⊠ 2 ⊠ 3 Go is

    an open source project.⊠ 4 ⊠ 5 It is the work of hundreds of contributors...⊠ 6 ⊠ 7 ## Before filing an issue⊠ 8 ⊠ 9 If you are unsure whether you have found...⊠ 10 https://groups.google.com/forum/#!forum/...⊠ 11 the behavior you are seeing is confirmed...⊠ 12 ⊠ 13 ## Filing issues⊠ 14 ⊠ 15 Sensitive security-related issues should...⊠ 16 See the [security policy](https://golang...⊠ 17 ⊠ 18 The recommended way to file an issue is ...⊠ 19 Otherwise, when filing an issue, make...⊠ 20 ⊠ ΧʔιϧҐஔ(19) ඳըҐஔ(4) ίϯςϯπͷߴ͞ (20) ඳըྖҬͷߴ͞ (14)
  9. ϩδοΫ func (l *Layer) DownCursor(val int, contentNum int) int {

    l.cursorPos.Y += val if l.cursorPos.Y > (contentNum - 1) { l.cursorPos.Y = contentNum - 1 } if l.cursorPos.Y > (l.drawPos.Y + l.win.Box.Height - 1) { l.drawPos.Y = l.cursorPos.Y - l.win.Box.Height + 1 } return l.cursorPos.Y }
  10. 1 # Contributing to Go⊠ 2 ⊠ 3 Go is

    an open source project.⊠ 4 ⊠ 5 It is the work of hundreds of contributors...⊠ 6 ⊠ 7 ## Before filing an issue⊠ 8 ⊠ 9 If you are unsure whether you have found...⊠ 10 https://groups.google.com/forum/#!forum/...⊠ 11 the behavior you are seeing is confirmed...⊠ 12 ⊠ 13 ## Filing issues⊠ 14 ⊠ 15 Sensitive security-related issues should...⊠ 16 See the [security policy](https://golang...⊠ 17 ⊠ 18 The recommended way to file an issue is ...⊠ 19 Otherwise, when filing an issue, make...⊠ 20 ⊠ ΧʔιϧҐஔ(19) ඳըҐஔ(4) ίϯςϯπͷߴ͞ (20) ඳըྖҬͷߴ͞ (14)
  11. ࣗݾ঺հ • େڮฏ࿨ (Toshikazu.Ohashi) • @lighttiger2505 • iRidge, Inc. •

    ΤϯδχΞืूத!! • αʔόαΠυΤϯδχΞ • Vim Go Vim Vim Go Go Vim ...Python