Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
crossword
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Silas Dohm
crossword
Commits
1dd93acd
Commit
1dd93acd
authored
Mar 20, 2022
by
Silas Dohm
Browse files
Options
Downloads
Patches
Plain Diff
new keyboard controls
parent
67534b81
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
sketch.js
+66
-20
66 additions, 20 deletions
sketch.js
with
66 additions
and
20 deletions
sketch.js
+
66
−
20
View file @
1dd93acd
...
...
@@ -22,7 +22,7 @@ class Cell {
//draw hintNr
if
(
this
.
hintNr
)
{
ctx
.
fillStyle
=
"
black
"
;
ctx
.
font
=
"
14
px Consolas
"
;
ctx
.
font
=
size
/
5
+
"
px Consolas
"
;
ctx
.
fillText
(
this
.
hintNr
,
this
.
x
*
size
+
4
,
(
this
.
y
)
*
size
+
15
);
}
}
...
...
@@ -213,24 +213,25 @@ function logKey(e) {
activeCell
=
activeCell
.
neighbour
[
0
];
break
;
case
"
I
"
:
//start of horizontal word
if
(
activeCell
.
word
[
0
])
activeCell
=
activeCell
.
word
[
0
].
chars
[
0
];
forceValidOrientation
();
if
(
activeCell
.
word
[
m_orientation
])
activeCell
=
activeCell
.
word
[
m_orientation
].
chars
[
0
];
case
"
R
"
:
case
"
i
"
:
forceValidOrientation
();
activeMode
=
mode
.
insert
;
m_orientation
=
0
;
break
;
case
"
O
"
:
if
(
activeCell
.
word
[
1
])
activeCell
=
activeCell
.
word
[
1
].
chars
[
0
];
case
"
o
"
:
activeMode
=
mode
.
insert
;
m_orientation
=
1
;
break
;
// case "O":
// if (activeCell.word[1])
// activeCell = activeCell.word[1].chars[0];
// case "o":
// activeMode = mode.insert;
// m_orientation = 1;
// break;
case
"
a
"
:
activeCell
=
activeCell
.
neighbour
[
2
];
activeCell
=
m_orientation
?
activeCell
.
neighbour
[
3
]
:
activeCell
.
neighbour
[
2
];
forceValidOrientation
();
activeMode
=
mode
.
insert
;
m_orientation
=
0
;
break
;
case
"
x
"
:
activeCell
.
currentChar
=
""
;
...
...
@@ -240,15 +241,54 @@ function logKey(e) {
break
;
case
"
B
"
:
case
"
b
"
:
activeCell
=
activeCell
.
word
[
m_orientation
].
chars
[
0
].
neighbour
[
m_orientation
?
1
:
0
].
word
[
m_orientation
].
chars
[
0
];
var
x
=
activeCell
.
x
;
var
y
=
activeCell
.
y
;
while
(
true
)
{
if
(
m_orientation
)
{
//vertical
y
=
(
y
+
rows
-
1
)
%
rows
;
if
(
y
%
columns
==
rows
-
1
)
x
=
(
x
+
columns
-
1
)
%
columns
;
}
else
{
//horizontal
x
=
(
x
+
columns
-
1
)
%
columns
;
if
(
x
%
columns
==
columns
-
1
)
y
=
(
y
+
rows
-
1
)
%
rows
;
}
if
(
mycell
[
x
][
y
].
word
[
m_orientation
]
&&
mycell
[
x
][
y
].
word
[
m_orientation
]
!=
activeCell
.
word
[
m_orientation
])
{
activeCell
=
mycell
[
x
][
y
].
word
[
m_orientation
].
chars
[
0
];
break
;
}
}
break
;
case
"
W
"
:
case
"
w
"
:
activeCell
=
activeCell
.
word
[
m_orientation
].
chars
[
activeCell
.
word
[
m_orientation
].
chars
.
length
-
1
].
neighbour
[
m_orientation
?
3
:
2
];
var
x
=
activeCell
.
x
;
var
y
=
activeCell
.
y
;
while
(
true
)
{
if
(
m_orientation
)
{
//vertical
y
=
(
y
+
1
)
%
rows
;
if
(
y
%
columns
==
0
)
x
=
(
x
+
1
)
%
columns
;
}
else
{
//horizontal
x
=
(
x
+
1
)
%
columns
;
if
(
x
%
columns
==
0
)
y
=
(
y
+
1
)
%
rows
;
}
if
(
mycell
[
x
][
y
].
word
[
m_orientation
]
&&
mycell
[
x
][
y
].
word
[
m_orientation
]
!=
activeCell
.
word
[
m_orientation
])
{
activeCell
=
mycell
[
x
][
y
];
break
;
}
}
break
;
case
"
`
"
:
activeCell
.
currentChar
=
activeCell
.
actualChar
;
break
;
case
"
q
"
:
//swap orientation - key still undecided
m_orientation
=
m_orientation
?
0
:
1
;
//invert orientation
break
;
default
:
break
;
}
...
...
@@ -267,9 +307,14 @@ aCanvas.addEventListener('mousedown', function (e) { //mouse navigation
if
(
activeCell
==
lastCell
)
m_orientation
=
m_orientation
?
0
:
1
;
//invert orientation
activeMode
=
mode
.
insert
;
forceValidOrientation
();
endInput
();
}
});
function
forceValidOrientation
()
{
if
(
!
activeCell
.
word
[
m_orientation
])
//
m_orientation
=
m_orientation
?
0
:
1
;
//invert orientation
}
function
endInput
()
{
if
(
activeMode
==
mode
.
insert
)
{
statusBar
.
style
.
display
=
'
block
'
;
...
...
@@ -277,8 +322,9 @@ function endInput() {
else
statusBar
.
style
.
display
=
'
none
'
;
if
(
!
activeCell
.
word
[
m_orientation
])
//
m_orientation
=
m_orientation
?
0
:
1
;
//invert orientation
// if (!activeCell.word[m_orientation]) //
// m_orientation = m_orientation ? 0 : 1; //invert orientation
if
(
lastCell
.
word
[
0
])
//clear highlight
lastCell
.
word
[
0
].
clearHighlight
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment