Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
itdan3344
stb
提交
3f17b24d
S
stb
项目概览
itdan3344
/
stb
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
stb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3f17b24d
编写于
4月 14, 2015
作者:
S
Sean Barrett
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make sure all libs compile as C++
上级
cbcbaff8
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
112 addition
and
6 deletion
+112
-6
stb_leakcheck.h
stb_leakcheck.h
+2
-2
stretchy_buffer.h
stretchy_buffer.h
+3
-2
tests/stb.dsp
tests/stb.dsp
+4
-0
tests/stb_cpp.cpp
tests/stb_cpp.cpp
+0
-1
tests/test_cpp_compilation.cpp
tests/test_cpp_compilation.cpp
+103
-1
未找到文件。
stb_leakcheck.h
浏览文件 @
3f17b24d
// stb_leakcheck.h - v0.
1
- quick & dirty malloc leak-checking - public domain
// stb_leakcheck.h - v0.
2
- quick & dirty malloc leak-checking - public domain
#ifdef STB_LEAKCHECK_IMPLEMENTATION
#undef STB_LEAKCHECK_IMPLEMENTATION // don't implenment more than once
...
...
@@ -27,7 +27,7 @@ static stb_leakcheck_malloc_info *mi_head;
void
*
stb_leakcheck_malloc
(
size_t
sz
,
char
*
file
,
int
line
)
{
stb_leakcheck_malloc_info
*
mi
=
malloc
(
sz
+
sizeof
(
*
mi
));
stb_leakcheck_malloc_info
*
mi
=
(
stb_leakcheck_malloc_info
*
)
malloc
(
sz
+
sizeof
(
*
mi
));
if
(
mi
==
NULL
)
return
mi
;
mi
->
file
=
file
;
mi
->
line
=
line
;
...
...
stretchy_buffer.h
浏览文件 @
3f17b24d
// stretchy_buffer.h - v1.0
1
- public domain - nothings.org/stb
// stretchy_buffer.h - v1.0
2
- public domain - nothings.org/stb
// a vector<>-like dynamic array for C
//
// version history:
// 1.02 - compiles as C++, but untested
// 1.01 - added a "common uses" documentation section
// 1.0 - fixed bug in the version I posted prematurely
// 0.9 - rewrite to try to avoid strict-aliasing optimization
...
...
@@ -193,7 +194,7 @@ static void * stb__sbgrowf(void *arr, int increment, int itemsize)
int
dbl_cur
=
arr
?
2
*
stb__sbm
(
arr
)
:
0
;
int
min_needed
=
stb_sb_count
(
arr
)
+
increment
;
int
m
=
dbl_cur
>
min_needed
?
dbl_cur
:
min_needed
;
int
*
p
=
realloc
(
arr
?
stb__sbraw
(
arr
)
:
0
,
itemsize
*
m
+
sizeof
(
int
)
*
2
);
int
*
p
=
(
int
*
)
realloc
(
arr
?
stb__sbraw
(
arr
)
:
0
,
itemsize
*
m
+
sizeof
(
int
)
*
2
);
if
(
p
)
{
if
(
!
arr
)
p
[
1
]
=
0
;
...
...
tests/stb.dsp
浏览文件 @
3f17b24d
...
...
@@ -150,6 +150,10 @@ SOURCE=..\stb_vorbis.c
# End Source File
# Begin Source File
SOURCE=..\stb_voxel_render.h
# End Source File
# Begin Source File
SOURCE=..\stretchy_buffer.h
# End Source File
# Begin Source File
...
...
tests/stb_cpp.cpp
浏览文件 @
3f17b24d
...
...
@@ -80,4 +80,3 @@ int main(int argc, char **argv)
}
return
0
;
}
\ No newline at end of file
tests/test_cpp_compilation.cpp
浏览文件 @
3f17b24d
...
...
@@ -8,7 +8,6 @@
#define STB_HERRINGBONE_WANG_TILE_IMPLEMENTATION
#define STB_RECT_PACK_IMPLEMENTATION
#define STB_VOXEL_RENDER_IMPLEMENTATION
#define STBVOX_CONFIG_MODE 1
#define STBI_MALLOC my_malloc
#define STBI_FREE my_free
...
...
@@ -27,9 +26,112 @@ void my_free(void *) { }
#include "stb_c_lexer.h"
#include "stb_divide.h"
#include "stb_herringbone_wang_tile.h"
#define STBVOX_CONFIG_MODE 1
#include "stb_voxel_render.h"
#define STBTE_DRAW_RECT(x0,y0,x1,y1,color) do ; while(0)
#define STBTE_DRAW_TILE(x,y,id,highlight,data) do ; while(0)
#define STB_TILEMAP_EDITOR_IMPLEMENTATION
#include "stb_tilemap_editor.h"
#include "stb_easy_font.h"
#define STB_LEAKCHECK_IMPLEMENTATION
#include "stb_leakcheck.h"
#define STB_IMAGE_RESIZE_IMPLEMENTATION
#include "stb_image_resize.h"
#include "stretchy_buffer.h"
////////////////////////////////////////////////////////////
//
// text edit
#include <stdlib.h>
#include <string.h> // memmove
#include <ctype.h> // isspace
#define STB_TEXTEDIT_CHARTYPE char
#define STB_TEXTEDIT_STRING text_control
// get the base type
#include "stb_textedit.h"
// define our editor structure
typedef
struct
{
char
*
string
;
int
stringlen
;
STB_TexteditState
state
;
}
text_control
;
// define the functions we need
void
layout_func
(
StbTexteditRow
*
row
,
STB_TEXTEDIT_STRING
*
str
,
int
start_i
)
{
int
remaining_chars
=
str
->
stringlen
-
start_i
;
row
->
num_chars
=
remaining_chars
>
20
?
20
:
remaining_chars
;
// should do real word wrap here
row
->
x0
=
0
;
row
->
x1
=
20
;
// need to account for actual size of characters
row
->
baseline_y_delta
=
1.25
;
row
->
ymin
=
-
1
;
row
->
ymax
=
0
;
}
int
delete_chars
(
STB_TEXTEDIT_STRING
*
str
,
int
pos
,
int
num
)
{
memmove
(
&
str
->
string
[
pos
],
&
str
->
string
[
pos
+
num
],
str
->
stringlen
-
(
pos
+
num
));
str
->
stringlen
-=
num
;
return
1
;
// always succeeds
}
int
insert_chars
(
STB_TEXTEDIT_STRING
*
str
,
int
pos
,
STB_TEXTEDIT_CHARTYPE
*
newtext
,
int
num
)
{
str
->
string
=
(
char
*
)
realloc
(
str
->
string
,
str
->
stringlen
+
num
);
memmove
(
&
str
->
string
[
pos
+
num
],
&
str
->
string
[
pos
],
str
->
stringlen
-
pos
);
memcpy
(
&
str
->
string
[
pos
],
newtext
,
num
);
str
->
stringlen
+=
num
;
return
1
;
// always succeeds
}
// define all the #defines needed
#define KEYDOWN_BIT 0x80000000
#define STB_TEXTEDIT_STRINGLEN(tc) ((tc)->stringlen)
#define STB_TEXTEDIT_LAYOUTROW layout_func
#define STB_TEXTEDIT_GETWIDTH(tc,n,i) (1) // quick hack for monospaced
#define STB_TEXTEDIT_KEYTOTEXT(key) (((key) & KEYDOWN_BIT) ? 0 : (key))
#define STB_TEXTEDIT_GETCHAR(tc,i) ((tc)->string[i])
#define STB_TEXTEDIT_NEWLINE '\n'
#define STB_TEXTEDIT_IS_SPACE(ch) isspace(ch)
#define STB_TEXTEDIT_DELETECHARS delete_chars
#define STB_TEXTEDIT_INSERTCHARS insert_chars
#define STB_TEXTEDIT_K_SHIFT 0x40000000
#define STB_TEXTEDIT_K_CONTROL 0x20000000
#define STB_TEXTEDIT_K_LEFT (KEYDOWN_BIT | 1) // actually use VK_LEFT, SDLK_LEFT, etc
#define STB_TEXTEDIT_K_RIGHT (KEYDOWN_BIT | 2) // VK_RIGHT
#define STB_TEXTEDIT_K_UP (KEYDOWN_BIT | 3) // VK_UP
#define STB_TEXTEDIT_K_DOWN (KEYDOWN_BIT | 4) // VK_DOWN
#define STB_TEXTEDIT_K_LINESTART (KEYDOWN_BIT | 5) // VK_HOME
#define STB_TEXTEDIT_K_LINEEND (KEYDOWN_BIT | 6) // VK_END
#define STB_TEXTEDIT_K_TEXTSTART (STB_TEXTEDIT_K_LINESTART | STB_TEXTEDIT_K_CONTROL)
#define STB_TEXTEDIT_K_TEXTEND (STB_TEXTEDIT_K_LINEEND | STB_TEXTEDIT_K_CONTROL)
#define STB_TEXTEDIT_K_DELETE (KEYDOWN_BIT | 7) // VK_DELETE
#define STB_TEXTEDIT_K_BACKSPACE (KEYDOWN_BIT | 8) // VK_BACKSPACE
#define STB_TEXTEDIT_K_UNDO (KEYDOWN_BIT | STB_TEXTEDIT_K_CONTROL | 'z')
#define STB_TEXTEDIT_K_REDO (KEYDOWN_BIT | STB_TEXTEDIT_K_CONTROL | 'y')
#define STB_TEXTEDIT_K_INSERT (KEYDOWN_BIT | 9) // VK_INSERT
#define STB_TEXTEDIT_K_WORDLEFT (STB_TEXTEDIT_K_LEFT | STB_TEXTEDIT_K_CONTROL)
#define STB_TEXTEDIT_K_WORDRIGHT (STB_TEXTEDIT_K_RIGHT | STB_TEXTEDIT_K_CONTROL)
#define STB_TEXTEDIT_K_PGUP (KEYDOWN_BIT | 10) // VK_PGUP -- not implemented
#define STB_TEXTEDIT_K_PGDOWN (KEYDOWN_BIT | 11) // VK_PGDOWN -- not implemented
#define STB_TEXTEDIT_IMPLEMENTATION
#include "stb_textedit.h"
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录