commit f06d00ef561c6c478a5a2fd6d1a2d104e5c5b9b7
parent 11d5fdb9a4435c8211d0f62b9350bf03234428aa
Author: Vetle Haflan <vetle@haflan.dev>
Date: Fri, 28 Apr 2023 16:41:33 +0200
Add some lua and web experiments
Diffstat:
8 files changed, 196 insertions(+), 0 deletions(-)
diff --git a/css/style.css b/css/style.css
@@ -0,0 +1,41 @@
+body{
+ max-width:650px;
+ margin:40px auto;
+ padding:0 10px;
+ font:18px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
+ color:#444
+}
+
+h1,h2,h3{line-height:1.2}
+
+h2 {
+ margin-top: 2em;
+}
+
+li{line-height:1}
+
+@media (prefers-color-scheme: dark){
+ body{
+ color:#c9d1d9;
+ background:#0d1117;
+ }
+ a:link{color:#58a6ff}
+ a:visited{color:#8e96f0}
+}
+
+.description {
+ font-size: 16px;
+}
+
+table {
+ width: 100%;
+}
+
+td {
+ vertical-align: top;
+}
+
+a {
+ text-decoration: none;
+ color: black;
+}
diff --git a/lua/luaexp/index.lua b/lua/luaexp/index.lua
@@ -0,0 +1,25 @@
+#!/usr/bin/env lua
+if #arg < 1 then
+ print('Use: '..arg[0]..' <dir>')
+ return
+end
+
+function Set (list)
+ local set = {}
+ for _, l in ipairs(list) do set[l] = true end
+ return set
+end
+
+local pf = io.popen('ls -a "'..arg[1]..'"')
+local matches = {}
+print(pf:read("*a"))
+for filename in pf:lines() do
+ if filename == '.' or filename == '..' then
+ goto continue
+ end
+ table.insert(matches, filename)
+ ::continue::
+end
+
+matches = Set(matches)
+print(matches)
diff --git a/lua/luaexp/nvim.adoc b/lua/luaexp/nvim.adoc
@@ -0,0 +1,3 @@
+Avoid NVIM auto-inserting the first complete suggestion:
+
+ set completeopt=menu,noinsert
diff --git a/lua/luaexp/search.lua b/lua/luaexp/search.lua
@@ -0,0 +1,5 @@
+#!/usr/bin/env lua
+local git_root = io.popen('printf $(git rev-parse --show-toplevel 2> /dev/null || pwd)'):read("*a")
+print(git_root)
+local root_list = io.popen('ls -A "'..git_root..'"'):read("*a")
+print(root_list)
diff --git a/lua/luaexp/test.lua b/lua/luaexp/test.lua
@@ -0,0 +1,6 @@
+function spew()
+ local output = vim.fn.system(vim.api.nvim_get_current_line())
+ vim.api.nvim_put({ output }, "l", true, false)
+end
+
+vim.api.nvim_set_keymap("n", "<leader>a", ":lua spew()<CR>", { noremap = true })
diff --git a/web/freestyle/index.html b/web/freestyle/index.html
@@ -0,0 +1,83 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Freestyle</title>
+</head>
+<body style="margin:0;padding:0;height:100vh;width:100vw;">
+ <div id="board" style="height: 100%;width: 100%;background-color: gainsboro;"></div>
+ <script type="text/javascript">
+ let board = document.querySelector('#board')
+ let counter = 0;
+
+
+ function moveDone(e) {
+ e.preventDefault()
+ if (!moving.value) return
+ let dashboard = document.querySelector('#dashboard')
+ if (!dashboard) return
+ moving.value = false
+ let y = e.clientY
+ let wh = window.innerHeight
+ if (y > wh * size.value.LimitHalfSmall) {
+ dashboard.style.top = wh * size.value.SnapSmall + 'px'
+ } else if (y < wh * size.value.LimitFullHalf) {
+ dashboard.style.top = wh * size.value.SnapFull + 'px'
+ } else {
+ dashboard.style.top = wh * size.value.SnapHalf + 'px'
+ }
+ }
+
+
+
+
+ board.addEventListener('click', (e) => {
+ e.preventDefault()
+ if (e.target.getAttribute('id') !== 'board') return
+ console.log(e.target)
+ let x = e.clientX
+ let y = e.clientY
+ let note = document.createElement('div')
+ note.innerHTML = `
+ <div class="toolbar">- X</div>
+ <div class="notewrap"><textarea style="background-color: gainsboro;"></textarea></div>
+ `
+ note.id = 'new-note-' + counter++
+ note.style.position = 'fixed'
+ note.style.border = '1px solid grey'
+ note.style.backgroundClip = 'gainsboro'
+ note.style.left = (x - 15) + 'px'
+ note.style.top = (y - 15) + 'px'
+ note.style.width = 'fit-content'
+ note.style.height = 'fit-content'
+ board.appendChild(note)
+ let textarea = document.querySelector(`#${note.id} .notewrap textarea`)
+ let toolbar = document.querySelector(`#${note.id} .toolbar`)
+ textarea.focus()
+ let moving = false
+ toolbar.addEventListener('pointerdown', (e) => {
+ e.preventDefault()
+ moving = true
+ }, true)
+ function moveDone(e) {
+ moving = false
+ }
+ document.addEventListener('pointercancel', moveDone, true)
+ document.addEventListener('pointerup', moveDone, true)
+ document.addEventListener('pointermove', (e) => {
+ e.preventDefault()
+ if (!note) return
+ if (!moving) return
+ let y = e.clientY
+ let x = e.clientX
+ note.style.top = (y - 10) + 'px'
+ note.style.left = (x - 10) + 'px'
+ }, true)
+
+
+ })
+ </script>
+</body>
+</html>+
\ No newline at end of file
diff --git a/web/webcomp-routing/index.html b/web/webcomp-routing/index.html
@@ -0,0 +1,23 @@
+<html>
+<body>
+ <a href="#/mod">Testing</a>
+ <a href="#/tastin">Tastin</a>
+ <a href="#/yes/this">Yes</a>
+ <div id="cont"></div>
+ <script type="module" src="./mod.js"></script>
+ <script type="text/javascript">
+ function goto(e) {
+ console.log(location.hash)
+ switch (location.hash) {
+ case '#/mod':
+ document.querySelector('#cont').innerHTML = '<m-mod></m-mod>'
+ break;
+ default:
+ document.querySelector('#cont').innerHTML = location.hash
+ }
+ }
+ window.addEventListener('hashchange', goto)
+ goto()
+ </script>
+<body>
+</html>
diff --git a/web/webcomp-routing/mod.js b/web/webcomp-routing/mod.js
@@ -0,0 +1,9 @@
+customElements.define("m-mod", class extends HTMLElement {
+ constructor() {
+ super()
+ }
+ connectedCallback() {
+ console.log('huuuuuuuu')
+ this.innerHTML = '<b>Great successssss</b>'
+ }
+})