Skip to content

Commit

Permalink
0.0.16 (#37)
Browse files Browse the repository at this point in the history
* cleanup leftover print

* fix jumping keyboard heading

* fix enterDown

* remove old commented code

* workaround for #26

* update version

* fix selected layout in html

Co-authored-by: elder-n00b <[email protected]>
  • Loading branch information
RasmusLindroth and elder-n00b authored Oct 24, 2022
1 parent 78c57ef commit 99e368e
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 63 deletions.
2 changes: 1 addition & 1 deletion i3keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/RasmusLindroth/i3keys/web"
)

const version string = "0.0.15"
const version string = "0.0.16"

func helpText(exitCode int) {
fmt.Print("Usage:\n\n\ti3keys [-i|-s] <command> [arguments]\n")
Expand Down
6 changes: 5 additions & 1 deletion i3parse/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,11 @@ func parseBindingParts(parts []string) ([]string, string, string) {
if mod[0] == '$' {
continue
}
modifiers[i] = strings.Title(mod)
mod = strings.Title(mod)
if mod == "Alt" {
mod = "Mod1" // rough fix for #26
}
modifiers[i] = mod
}

var cmdParts []string
Expand Down
34 changes: 0 additions & 34 deletions json/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,42 +37,8 @@ func Output(wm string, layout string) {
}

modifiers := xlib.GetModifiers()
/*
groups := i3parse.GetModifierGroups(keys)

var keyboards []keyboard.Keyboard
for _, group := range groups {
kb, err := keyboard.MapKeyboard(layout, group, modifiers)
if err == nil {
keyboards = append(keyboards, kb)
}
}
*/
var jsonBoards []KeyboardModesJSON
/*
defaultBoard := KeyboardModesJSON{
Name: "Default",
}
for _, kb := range keyboards {
b := KeyboardModifierJSON{
Modifiers: kb.Modifiers,
}
for i, keyRow := range kb.Keys {
for _, key := range keyRow {
binding := KeyJSON{
Row: i,
Modifier: key.Modifier,
InUse: key.InUse,
Symbol: key.Symbol,
Command: key.Binding.Command,
}
b.Keys = append(b.Keys, binding)
}
}
defaultBoard.ModifierGroups = append(defaultBoard.ModifierGroups, b)
}
jsonBoards = append(jsonBoards, defaultBoard)
*/
for _, mode := range modes {
groups := i3parse.GetModifierGroups(mode.Bindings)

Expand Down
12 changes: 7 additions & 5 deletions web/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ type KeyInfo struct {
Key_size string
Key_empty bool
Key_usage int
Key_enter int
Key keyboard.Key
}

Expand All @@ -65,12 +64,12 @@ var layoutMaps = LayoutMaps{
}

func (h Handler) keyInfo(kbd keyboard.Keyboard) <-chan KeyInfo {
//kbLayout := h.Data.Layouts[h.Data.LayoutName]
kbLayoutMap := h.Data.LayoutMaps[h.Data.LayoutName]

ki := make(chan KeyInfo)
go func() {
enterHit := 0
enterKey := keyboard.Key{}
for i, rowMap := range kbLayoutMap {
k := 0
for j, key_size := range rowMap {
Expand All @@ -87,13 +86,16 @@ func (h Handler) keyInfo(kbd keyboard.Keyboard) <-chan KeyInfo {
}
if key_size == "enterUp" {
enterHit = gHit
enterKey = key
}
k++
}
if key_size == "enterDown" {
gHit = enterHit
ki <- KeyInfo{i, j, k, key_size, false, gHit, enterKey}
} else {
ki <- KeyInfo{i, j, k, key_size, key_empty, gHit, key}
}
ki <- KeyInfo{i, j, k, key_size, key_empty, gHit, enterHit, key}
}
}
close(ki)
Expand Down Expand Up @@ -125,10 +127,10 @@ func readResource(filename string) (string, bool) {
pathname = realName(path.Join(pathname, filename))

if buf, err := os.ReadFile(pathname); err == nil {
println("read resource from '" + pathname + "'")
//println("read resource from '" + pathname + "'")
return string(buf), true
} else {
println("could not read resource from '" + pathname + "', using built-in")
//println("could not read resource from '" + pathname + "', using built-in")
return "", false
}
}
Expand Down
33 changes: 20 additions & 13 deletions web/res/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -116,34 +116,40 @@ body {
display: inline;
}


#keyboard-holder {
margin-left: var(--grid-gap-h);
}

#keyboard-holder > div {
.keyboard {
margin-bottom: 2em;
height: 100vh;
}

#keyboard-holder .keyboard-heading {
.keyboard-heading {
position: sticky;
height: 2.25em;
top: 2em;
padding-top: 0.25em;
background-color: var(--main-bg);
}

#keyboard-holder .keyboard-heading > h2 {
display: inline;
.keyboard-heading span {
font-size: x-large;
margin-right: 1ch;
}

.keyboard-heading .mode {
color: var(--main-fg-max);
margin-right: 2ch;
font-weight: bold;
}

#keyboard-holder .keyboard-heading > h3 {
display: inline;
.keyboard-heading .keyb {
color: var(--main-fg-dim);
font-weight: normal;
font-size: larger;
}

.keyboard-heading .default, #toc-panel .default {
font-style: italic;
}

#key-info {
Expand Down Expand Up @@ -180,11 +186,8 @@ body {
}


span.default {
font-style: italic;
}

.keyboard {
.keyboard-layout {
display: grid;
grid-template-columns: repeat(1000, calc(var(--key-size) / 4 - 0.4vw));
grid-template-rows: repeat(6, var(--key-size));
Expand Down Expand Up @@ -274,6 +277,10 @@ span.default {
margin-top: calc(-1 * var(--grid-gap-v) - 1.25px); /* still needs the .25 ? */
}

.enterDown > .txt {
display: none;
}

.row-0 {
grid-row-start: 1;
}
Expand Down
14 changes: 7 additions & 7 deletions web/res/index.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
<ul id="options-panel">
<li>
<label for="opt-layout">layout:</label>
<select id="opt-layout" name="opt-layout" value={{$.LayoutName}}>
<select id="opt-layout" name="opt-layout">
{{- range $lmap_i,$lmap := .LayoutMaps -}}
{{- $selected := eq $lmap_i $.LayoutName -}}
<option value="{{$lmap_i}}" {{if $selected}}selected="true"{{end}}><!-- id="opt-layout-{{$lmap_i}}" -->
<option value="{{$lmap_i}}" {{if $selected}}selected{{end}}>
{{$lmap_i}}
</option>
{{- end -}}
Expand All @@ -52,12 +52,13 @@
<div id="keyboard-holder">
{{- range $mode_i,$mode := $layoutData -}}
{{- range $keyb_i,$keyb := .Keyboards -}}
<div id="mode_{{$mode_i}}.{{$keyb_i}}">
<div class="keyboard" id="mode_{{$mode_i}}.{{$keyb_i}}">
<div class="keyboard-heading">
<h2>{{if ne $mode.Name ""}}<span>{{$mode.Name}}</span>{{else}}<span class="default">default</span>{{end}}</h2>
<h3>{{if ne $keyb.Name ""}}<span>{{$keyb.Name}}</span>{{else}}<span class="default">no modifiers</span>{{end}}</h3>
{{if ne $mode.Name ""}}<span class="mode">{{$mode.Name}}</span>{{else}}<span class="mode default">default</span>{{end}}
{{if ne $keyb.Name ""}}<span class="keyb">{{$keyb.Name}}</span>{{else}}<span class="keyb default">no modifiers</span>{{end}}
<span class="default"></span><!-- dummy one always italics to fix an alignment issue the dumb way -->
</div>
<div class="keyboard">
<div class="keyboard-layout">
{{- $usage_classes := mkslice "" "key-modifier" "key-used" -}}
{{- range keyinfo $keyb -}}
{{- $usage := index $usage_classes .Key_usage -}}
Expand All @@ -81,7 +82,6 @@
</div>
<div id="key-info">
<table>
<!-- TODO: range mkslice here -->
<tr><td class="ki-item ki-property">command</td> <td class="ki-item ki-value ki-bold" id="key-command"></td></tr>
<tr><td class="ki-item ki-property">identifier</td> <td class="ki-item ki-value" id="key-identifier"></td></tr>
<tr><td class="ki-item ki-property">symbol</td> <td class="ki-item ki-value" id="key-symbol"></td></tr>
Expand Down
3 changes: 1 addition & 2 deletions web/res/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function keyCaption(s) {

function splitSymbol(s) {
return s
.replaceAll(/grave|acute|left|right|slash/g," $&") // TODO: smarter, more complete regex
.replaceAll(/grave|acute|left|right|slash/g," $&")
.replaceAll("_"," ")
;
}
Expand Down Expand Up @@ -139,7 +139,6 @@ keyboardHolder.addEventListener('mouseover', event => {
for (el of keyElements) {
if (el == event.target) {
if (key = event.target.firstChild) { // key is actually .txt
// TODO: somehow generate from range
document.getElementById('key-command').innerHTML=key.dataset.bindcommand;
document.getElementById('key-symbol').innerHTML=key.dataset.symbol;
document.getElementById('key-symbolcode').innerHTML="0x"+parseInt(key.dataset.symbolcode).toString(16)+" ("+key.dataset.symbolcode+")";
Expand Down

0 comments on commit 99e368e

Please sign in to comment.