Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
システムライブラリに依存しないlessコマンドAPIの簡易版を作った
Search
wasanx25
May 18, 2019
1.8k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
システムライブラリに依存しないlessコマンドAPIの簡易版を作った
wasanx25
May 18, 2019
Featured
See All Featured
Designing Powerful Visuals for Engaging Learning
tmiket
1
610
How STYLIGHT went responsive
nonsquared
100
6.3k
BBQ
matthewcrist
90
10k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
35
2.9k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
GitHub's CSS Performance
jonrohan
1033
470k
Designing for humans not robots
tammielis
254
26k
AI: The stuff that nobody shows you
jnunemaker
PRO
10
1.2k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
500
How to build a perfect <img>
jonoalderson
1
6.1k
The Pragmatic Product Professional
lauravandoore
37
7.5k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
Transcript
γεςϜϥΠϒϥϦʹґଘ͠ͳ͍ LESSίϚϯυAPIͷ؆қ൛Λ࡞ͬͨ @WASANX25 2019/05/18 GO CONFERENCE 2019 SPRING
GOSS ▸ https://github.com/wasanx25/goss ▸ Go͔Βͦͷ··ςΩετΛ͚ͩ͢Ͱɺλʔϛφϧ্Ͱless Έ͍ͨʹදࣔ͢Δ func main() { data
:= "text, text\ntext,text" err := goss.Run(data) if err != nil { fmt.Println(err) os.Exit(1) } os.Exit(0) }
ͳΜͰ࡞ͬͨͷ͔ ▸ ࣗͰ࡞ͬͨsreqͱ͍͏ͷ͕͋ΓɺͦͷͨΊʹ࡞ͨ͠ ▸ https://github.com/wasanx25/sreq ▸ GoͰCLIπʔϧΛ࡞Δͱ͖ʹɺlessίϚϯυΛଧͨͳ͍ͨΊʹͲ͏͢Δ͔ߟ͔͑ͨͬ ͨ ▸ ཧ༝ɺ
▸ CLIπʔϧͰɺos/execΛ༻͠ͳ͍ ▸ Fileʹॻ͖ࠐ·ͤͳ͍ ▸ ͦͦOSʹless͕ೖͬͯͳ͍ ▸ Go͕ॻ͖͔͔ͨͬͨΒ
TCELLͱ͍͏OSSΛ͍ͬͯΔ ▸ https://github.com/gdamore/tcell func main() { tui, err := tcell.NewScreen()
if err != nil { fmt.Println(err) os.Exit(1) } if err = tui.Init(); err != nil { fmt.Println(err) os.Exit(1) } tui.SetContent(0, 0, 't', nil, tcell.StyleDefault) tui.SetContent(1, 0, 'e', nil, tcell.StyleDefault) tui.SetContent(2, 0, 's', nil, tcell.StyleDefault) tui.SetContent(3, 0, 't', nil, tcell.StyleDefault) tui.SetContent(0, 1, 's', []rune{'a','m','p','l','e'}, tcell.StyleDefault) tui.Show() time.Sleep(5 * time.Second) tui.Fini() } ▸ tuiɺtcell.Screen IntefaceΛ࣋ͭ
TCELLςετ͕͍͢͠ ▸ ςελϏϦςΟ͕ߴ͍ ▸ Πϕϯτʹର͢ΔςετɺWindowͷαΠζઃఆ͕Մೳ ▸ GetContents()ͰɺSetContent()ͨ͠༰ΛऔಘͰ͖Δ ▸ Screen InterfaceΛ֎෦͔Βೖ͢Δ͜ͱͰɺςετ͕͘͢͠Ͱ
͖Δ
TCELLͷςετ ▸ ઌ΄Ͳͷ࣮ߦαϯϓϧΛ sample() ͱ͍͏ϝιουʹஔ͘ func sample(tui tcell.Screen) { tui.SetContent(0,
0, 't', nil, tcell.StyleDefault) tui.SetContent(1, 0, 'e', nil, tcell.StyleDefault) tui.SetContent(2, 0, 's', nil, tcell.StyleDefault) tui.SetContent(3, 0, 't', nil, tcell.StyleDefault) tui.SetContent(0, 1, 's', []rune{'a', 'm', 'p', 'l', 'e'}, tcell.StyleDefault) }
TCELLͷςετ func TestSample(t *testing.T) { tui := tcell.NewSimulationScreen("") if err
:= tui.Init(); err != nil { t.Fatal(err) } tui.SetSize(10, 2) sample(tui) tui.Show() cells, _, _ := tui.GetContents() var runes []rune for i, cell := range cells { runes = append(runes, cell.Runes...) if (i+1)%10 == 0 { runes = append(runes, '\n') } } slice := []string{ "test \n", "sample \n", } expected := strings.Join(slice, "") actual := string(runes) if actual != expected { t.Errorf("expected=%v, got=%v", expected, actual) } } ▸ GetContents()ͷୈҰҾɺ []tcell.SimCell type ▸ []runeͳͲΛϑΟʔϧυʹ࣋ͭ ▸ tui.SetSize()͞Εͨใʹج͍ͮͯ TERMͷWindowαΠζΛܾΊΔ ▸ ʣจࣈͰຒ·Βͳ͔ͬͨͱ͜ ΖεϖʔεͰຒ·Δ
ύοέʔδͷߏ ▸ Drawer ▸ contentʢҾͰ͖ͬͯͨςΩετΛѻ͏ʣ ▸ numberʢߦ൪߸Λѻ͏ʣ ▸ positionerʢWrite͢ΔॴΛཧʣ ▸
্هೋͭɺ͜ΕΛϑΟʔϧυͱͯͦ͠ΕͧΕ ࣋ͭ ▸ Event ▸ eventʢΩʔTERMͷϦαΠζͷΠϕϯτΛཧʣ ▸ Offsetter ▸ offsetterʢॻ͖ࠐΉ༰ͷoffsetαΠζΛཧʣ ▸ Viewer ▸ viewerʢ্هΛཧͯ͠ɺ࣮ࡍʹදࣔͤ͞Δʣ
࣮ࡍͷλʔϛφϧͰݟΔߏମͷߏ ▸ Offsetڞ௨Ͱཧ͢Δ ▸ PositionDrawerͦΕͧΕͰ࣋ͭ ▸ eventʹΑͬͯoffset͕มಈ͢Δ ▸ ྫʣjΛଧͭͱ+1͞ΕΔ
None
ࣗݾհ ▸ @wasanx25 ▸ ຊۀ: Java, Kotlin, Spring Boot ▸
झຯ: Go, Ruby ▸ Goπʔϧ࡞Δ͙Β͍͔͠
͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠