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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
290
The Spectacular Lies of Maps
axbom
PRO
1
1k
Thoughts on Productivity
jonyablonski
76
5.4k
The untapped power of vector embeddings
frankvandijk
2
1.9k
How to Talk to Developers About Accessibility
jct
2
560
A Tale of Four Properties
chriscoyier
163
24k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
910
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
770
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
340
Game over? The fight for quality and originality in the time of robots
wayneb77
1
290
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.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πʔϧ࡞Δ͙Β͍͔͠
͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠