Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
SRB2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
STJr
SRB2
Commits
702b23ec
Commit
702b23ec
authored
Jan 8, 2020
by
James R.
Browse files
Options
Downloads
Patches
Plain Diff
Put the word jumping code in functions
parent
0d3c03cc
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!734
Rebase Keycodes only branch.
,
!653
Word jumping
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/console.c
+5
-44
5 additions, 44 deletions
src/console.c
src/doomdef.h
+2
-0
2 additions, 0 deletions
src/doomdef.h
src/m_misc.c
+37
-0
37 additions, 0 deletions
src/m_misc.c
src/m_misc.h
+8
-0
8 additions, 0 deletions
src/m_misc.h
with
52 additions
and
44 deletions
src/console.c
+
5
−
44
View file @
702b23ec
...
@@ -32,6 +32,7 @@
...
@@ -32,6 +32,7 @@
#include
"d_main.h"
#include
"d_main.h"
#include
"m_menu.h"
#include
"m_menu.h"
#include
"filesrch.h"
#include
"filesrch.h"
#include
"m_misc.h"
#ifdef _WINDOWS
#ifdef _WINDOWS
#include
"win32/win_main.h"
#include
"win32/win_main.h"
...
@@ -41,8 +42,6 @@
...
@@ -41,8 +42,6 @@
#include
"hardware/hw_main.h"
#include
"hardware/hw_main.h"
#endif
#endif
#define PUNCTUATION "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
#define MAXHUDLINES 20
#define MAXHUDLINES 20
static
boolean
con_started
=
false
;
// console has been initialised
static
boolean
con_started
=
false
;
// console has been initialised
...
@@ -822,61 +821,23 @@ boolean CON_Responder(event_t *ev)
...
@@ -822,61 +821,23 @@ boolean CON_Responder(event_t *ev)
if
(
input_cur
!=
0
)
if
(
input_cur
!=
0
)
{
{
if
(
ctrldown
)
if
(
ctrldown
)
{
input_cur
=
M_JumpWordReverse
(
inputlines
[
inputline
],
input_cur
);
int
(
*
is
)(
int
);
char
*
line
;
int
c
;
line
=
inputlines
[
inputline
];
c
=
line
[
--
input_cur
];
if
(
isspace
(
c
))
is
=
isspace
;
else
if
(
ispunct
(
c
))
is
=
ispunct
;
else
else
is
=
isalnum
;
c
=
(
*
is
)(
line
[
input_cur
]);
while
(
input_cur
>
0
&&
(
*
is
)(
line
[
input_cur
-
1
])
==
c
)
input_cur
--
;
}
else
{
--
input_cur
;
--
input_cur
;
}
}
}
if
(
!
shiftdown
)
if
(
!
shiftdown
)
input_sel
=
input_cur
;
input_sel
=
input_cur
;
return
true
;
return
true
;
}
}
else
if
(
key
==
KEY_RIGHTARROW
)
else
if
(
key
==
KEY_RIGHTARROW
)
{
{
if
(
ctrldown
)
if
(
input_cur
<
input_len
)
{
char
*
line
;
int
c
;
line
=
&
inputlines
[
inputline
][
input_cur
];
c
=
line
[
0
];
if
(
isspace
(
c
))
input_cur
+=
strspn
(
line
,
" "
);
else
if
(
ispunct
(
c
))
input_cur
+=
strspn
(
line
,
PUNCTUATION
);
else
{
{
if
(
isspace
(
line
[
1
]))
if
(
ctrldown
)
input_cur
+=
1
+
strspn
(
&
line
[
1
],
" "
);
input_cur
+=
M_JumpWord
(
&
inputlines
[
inputline
][
input_cur
]);
else
input_cur
+=
strcspn
(
line
,
" "
PUNCTUATION
);
}
}
else
else
{
if
(
input_cur
<
input_len
)
++
input_cur
;
++
input_cur
;
}
}
if
(
!
shiftdown
)
if
(
!
shiftdown
)
input_sel
=
input_cur
;
input_sel
=
input_cur
;
return
true
;
return
true
;
...
...
This diff is collapsed.
Click to expand it.
src/doomdef.h
+
2
−
0
View file @
702b23ec
...
@@ -541,6 +541,8 @@ INT32 I_GetKey(void);
...
@@ -541,6 +541,8 @@ INT32 I_GetKey(void);
#define PATHSEP "/"
#define PATHSEP "/"
#endif
#endif
#define PUNCTUATION "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
// Compile date and time and revision.
// Compile date and time and revision.
extern
const
char
*
compdate
,
*
comptime
,
*
comprevision
,
*
compbranch
;
extern
const
char
*
compdate
,
*
comptime
,
*
comprevision
,
*
compbranch
;
...
...
This diff is collapsed.
Click to expand it.
src/m_misc.c
+
37
−
0
View file @
702b23ec
...
@@ -2540,3 +2540,40 @@ void M_MkdirEach(const char *path, int start, int mode)
...
@@ -2540,3 +2540,40 @@ void M_MkdirEach(const char *path, int start, int mode)
{
{
M_MkdirEachUntil
(
path
,
start
,
-
1
,
mode
);
M_MkdirEachUntil
(
path
,
start
,
-
1
,
mode
);
}
}
int
M_JumpWord
(
const
char
*
line
)
{
int
c
;
c
=
line
[
0
];
if
(
isspace
(
c
))
return
strspn
(
line
,
" "
);
else
if
(
ispunct
(
c
))
return
strspn
(
line
,
PUNCTUATION
);
else
{
if
(
isspace
(
line
[
1
]))
return
1
+
strspn
(
&
line
[
1
],
" "
);
else
return
strcspn
(
line
,
" "
PUNCTUATION
);
}
}
int
M_JumpWordReverse
(
const
char
*
line
,
int
offset
)
{
int
(
*
is
)(
int
);
int
c
;
c
=
line
[
--
offset
];
if
(
isspace
(
c
))
is
=
isspace
;
else
if
(
ispunct
(
c
))
is
=
ispunct
;
else
is
=
isalnum
;
c
=
(
*
is
)(
line
[
offset
]);
while
(
offset
>
0
&&
(
*
is
)(
line
[
offset
-
1
])
==
c
)
offset
--
;
return
offset
;
}
This diff is collapsed.
Click to expand it.
src/m_misc.h
+
8
−
0
View file @
702b23ec
...
@@ -101,6 +101,14 @@ boolean M_IsPathAbsolute (const char *path);
...
@@ -101,6 +101,14 @@ boolean M_IsPathAbsolute (const char *path);
void
M_MkdirEach
(
const
char
*
path
,
int
start
,
int
mode
);
void
M_MkdirEach
(
const
char
*
path
,
int
start
,
int
mode
);
void
M_MkdirEachUntil
(
const
char
*
path
,
int
start
,
int
end
,
int
mode
);
void
M_MkdirEachUntil
(
const
char
*
path
,
int
start
,
int
end
,
int
mode
);
/* Return offset to the first word in a string. */
/* E.g. cursor += M_JumpWord(line + cursor); */
int
M_JumpWord
(
const
char
*
s
);
/* Return index of the last word behind offset bytes in a string. */
/* E.g. cursor = M_JumpWordReverse(line, cursor); */
int
M_JumpWordReverse
(
const
char
*
line
,
int
offset
);
// counting bits, for weapon ammo code, usually
// counting bits, for weapon ammo code, usually
FUNCMATH
UINT8
M_CountBits
(
UINT32
num
,
UINT8
size
);
FUNCMATH
UINT8
M_CountBits
(
UINT32
num
,
UINT8
size
);
...
...
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