Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libSDL
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
libSDL
Commits
1d79a9b5
Commit
1d79a9b5
authored
Jul 25, 2010
by
dewyatt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed markedText to have its own storage to resolve multiple bugs.
Changed an odd strcpy to a more appropriate strcat.
parent
aa3be46c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
testime.c
test/testime.c
+6
-6
No files found.
test/testime.c
View file @
1d79a9b5
...
@@ -25,7 +25,7 @@ TTF_Font *font;
...
@@ -25,7 +25,7 @@ TTF_Font *font;
SDL_Rect
textRect
,
markedRect
;
SDL_Rect
textRect
,
markedRect
;
Uint32
lineColor
,
backColor
;
Uint32
lineColor
,
backColor
;
SDL_Color
textColor
=
{
0
,
0
,
0
};
SDL_Color
textColor
=
{
0
,
0
,
0
};
char
text
[
MAX_TEXT_LENGTH
],
*
markedText
;
char
text
[
MAX_TEXT_LENGTH
],
markedText
[
SDL_TEXTEDITINGEVENT_TEXT_SIZE
]
;
void
usage
()
void
usage
()
{
{
...
@@ -124,7 +124,7 @@ void InitInput()
...
@@ -124,7 +124,7 @@ void InitInput()
text
[
0
]
=
0
;
text
[
0
]
=
0
;
markedRect
=
textRect
;
markedRect
=
textRect
;
markedText
=
NULL
;
markedText
[
0
]
=
0
;
SDL_StartTextInput
();
SDL_StartTextInput
();
}
}
...
@@ -178,7 +178,7 @@ void Redraw()
...
@@ -178,7 +178,7 @@ void Redraw()
cursorRect
.
h
=
h
;
cursorRect
.
h
=
h
;
SDL_FillRect
(
screen
,
&
markedRect
,
backColor
);
SDL_FillRect
(
screen
,
&
markedRect
,
backColor
);
if
(
markedText
)
if
(
markedText
[
0
]
)
{
{
#ifdef HAVE_SDL_TTF
#ifdef HAVE_SDL_TTF
RenderText
(
screen
,
font
,
markedText
,
markedRect
.
x
,
markedRect
.
y
,
textColor
);
RenderText
(
screen
,
font
,
markedText
,
markedRect
.
x
,
markedRect
.
y
,
textColor
);
...
@@ -293,13 +293,13 @@ int main(int argc, char *argv[])
...
@@ -293,13 +293,13 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"Keyboard: text input
\"
%s
\"\n
"
,
event
.
text
.
text
);
fprintf
(
stderr
,
"Keyboard: text input
\"
%s
\"\n
"
,
event
.
text
.
text
);
if
(
SDL_strlen
(
text
)
+
SDL_strlen
(
event
.
text
.
text
)
<
sizeof
(
text
))
if
(
SDL_strlen
(
text
)
+
SDL_strlen
(
event
.
text
.
text
)
<
sizeof
(
text
))
strc
py
(
text
+
SDL_strlen
(
text
)
,
event
.
text
.
text
);
strc
at
(
text
,
event
.
text
.
text
);
fprintf
(
stderr
,
"text inputed: %s
\n
"
,
text
);
fprintf
(
stderr
,
"text inputed: %s
\n
"
,
text
);
// After text inputed, we can clear up markedText because it
// After text inputed, we can clear up markedText because it
// is committed
// is committed
markedText
=
NULL
;
markedText
[
0
]
=
0
;
Redraw
();
Redraw
();
break
;
break
;
...
@@ -307,7 +307,7 @@ int main(int argc, char *argv[])
...
@@ -307,7 +307,7 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"text editing
\"
%s
\"
, selected range (%d, %d)
\n
"
,
fprintf
(
stderr
,
"text editing
\"
%s
\"
, selected range (%d, %d)
\n
"
,
event
.
edit
.
text
,
event
.
edit
.
start
,
event
.
edit
.
length
);
event
.
edit
.
text
,
event
.
edit
.
start
,
event
.
edit
.
length
);
markedText
=
event
.
edit
.
text
;
strcpy
(
markedText
,
event
.
edit
.
text
)
;
Redraw
();
Redraw
();
break
;
break
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment