git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@8 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-09-28 06:52:49 +00:00
parent 19eec89b60
commit bf857097e5
11 changed files with 2020 additions and 29 deletions

21
.clang-format Normal file
View File

@@ -0,0 +1,21 @@
---
# $Id: .clang-format 16 2025-01-30 10:59:29Z nishi $
Language: Cpp
UseTab: Always
TabWidth: 8
AlignConsecutiveAssignments:
Enabled: true
AlignConsecutiveDeclarations:
Enabled: true
IndentWidth: 8
PointerAlignment: Left
ColumnLimit: 0
AllowShortIfStatementsOnASingleLine: Always
AllowShortBlocksOnASingleLine: Never
AllowShortFunctionsOnASingleLine: Empty
AllowShortLoopsOnASingleLine: true
SpaceBeforeParens: Never
AlignEscapedNewlines: DontAlign
SortIncludes: false
AllowShortEnumsOnASingleLine: false
#IndentPPDirectives: AfterHash

View File

@@ -7,7 +7,7 @@ CFLAGS = -fPIC -Iinclude -D_MILSKO
LDFLAGS = LDFLAGS =
LIBS = LIBS =
L_OBJS = L_OBJS = src/ds.o src/core.o
ifeq ($(TARGET),NetBSD) ifeq ($(TARGET),NetBSD)
CFLAGS += -I/usr/X11R7/include -I/usr/pkg/include CFLAGS += -I/usr/X11R7/include -I/usr/pkg/include

18
include/Milsko/Core.h Normal file
View File

@@ -0,0 +1,18 @@
/* $Id$ */
#ifndef __MILSKO_CORE_H__
#define __MILSKO_CORE_H__
#ifdef _MILSKO
#include <Milsko/LowLevel.h>
typedef struct _Milsko {
HMILSKOLL lowlevel;
}* HMILSKO;
#else
typedef void* HMILSKO;
#endif
HMILSKO MilskoCreateWidget(HMILSKO parent, int x, int y, unsigned int width, unsigned int height);
void MilskoDestroyWidget(HMILSKO handle);
#endif

View File

@@ -1,10 +1,6 @@
/* $Id$ */ /* $Id$ */
#ifndef __MILSKO_PLATFORM_H__ #ifndef __MILSKO_LL_H__
#define __MILSKO_PLATFORM_H__ #define __MILSKO_LL_H__
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <Milsko/TypeDef.h> #include <Milsko/TypeDef.h>
@@ -16,16 +12,16 @@
#include <Milsko/GDI.h> #include <Milsko/GDI.h>
#endif #endif
#else #else
typedef void* HMILSKO; typedef void* HMILSKOLL;
typedef void* HMILSKOCOLOR; typedef void* HMILSKOCOLOR;
#endif #endif
HMILSKO MilskoLLCreate(HMILSKO parent, int x, int y, int width, int height); HMILSKOLL MilskoLLCreate(HMILSKOLL parent, int x, int y, int width, int height);
void MilskoLLDestroy(HMILSKO handle); void MilskoLLDestroy(HMILSKOLL handle);
void MilskoLLPolygon(HMILSKO handle, MilskoPoint* points, int points_count, HMILSKOCOLOR color); void MilskoLLPolygon(HMILSKOLL handle, MilskoPoint* points, int points_count, HMILSKOCOLOR color);
HMILSKOCOLOR MilskoLLAllocColor(HMILSKO handle, int r, int g, int b); HMILSKOCOLOR MilskoLLAllocColor(HMILSKOLL handle, int r, int g, int b);
void MilskoLLGetXYWH(HMILSKO handle, int* x, int* y, unsigned int* w, unsigned int* h); void MilskoLLGetXYWH(HMILSKOLL handle, int* x, int* y, unsigned int* w, unsigned int* h);
int MilskoLLPending(HMILSKO handle); int MilskoLLPending(HMILSKOLL handle);
void MilskoLLNextEvent(HMILSKO handle); void MilskoLLNextEvent(HMILSKOLL handle);
#endif #endif

9
include/Milsko/MachDep.h Normal file
View File

@@ -0,0 +1,9 @@
/* $Id$ */
#ifndef __MILSKO_MACHDEP_H__
#define __MILSKO_MACHDEP_H__
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#endif

View File

@@ -2,6 +2,8 @@
#ifndef __MILSKO_MILSKO_H__ #ifndef __MILSKO_MILSKO_H__
#define __MILSKO_MILSKO_H__ #define __MILSKO_MILSKO_H__
#include <Milsko/MachDep.h>
#include <Milsko/LowLevel.h> #include <Milsko/LowLevel.h>
#include <Milsko/Core.h>
#endif #endif

View File

@@ -5,7 +5,7 @@
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
typedef struct __Milsko { typedef struct _MilskoLowLevel {
Display* display; Display* display;
Window window; Window window;
GC gc; GC gc;
@@ -14,9 +14,9 @@ typedef struct __Milsko {
int y; int y;
unsigned int width; unsigned int width;
unsigned int height; unsigned int height;
}* HMILSKO; }* HMILSKOLL;
typedef struct __MilskoColor { typedef struct _MilskoColor {
unsigned long pixel; unsigned long pixel;
}* HMILSKOCOLOR; }* HMILSKOCOLOR;

10
src/core.c Normal file
View File

@@ -0,0 +1,10 @@
/* $Id$ */
#include <Milsko/Milsko.h>
HMILSKO MilskoCreateWidget(HMILSKO parent, int x, int y, unsigned int width, unsigned int height) {
HMILSKO h = malloc(sizeof(*h));
}
void MilskoDestroyWidget(HMILSKO handle) {
free(handle);
}

3
src/ds.c Normal file
View File

@@ -0,0 +1,3 @@
/* $Id$ */
#define STB_DS_IMPLEMENTATION
#include "stb_ds.h"

1934
src/stb_ds.h Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +1,11 @@
/* $Id$ */ /* $Id$ */
#include <Milsko/Milsko.h> #include <Milsko/Milsko.h>
#include <stdlib.h>
static unsigned long mask = ExposureMask | StructureNotifyMask | ButtonPressMask | ButtonReleaseMask; static unsigned long mask = ExposureMask | StructureNotifyMask | ButtonPressMask | ButtonReleaseMask;
HMILSKO MilskoLLCreate(HMILSKO parent, int x, int y, int width, int height) { HMILSKOLL MilskoLLCreate(HMILSKOLL parent, int x, int y, int width, int height) {
HMILSKO r; HMILSKOLL r;
Window p; Window p;
r = malloc(sizeof(*r)); r = malloc(sizeof(*r));
r->x = x; r->x = x;
@@ -32,13 +30,13 @@ HMILSKO MilskoLLCreate(HMILSKO parent, int x, int y, int width, int height) {
return r; return r;
} }
void MilskoLLDestroy(HMILSKO handle) { void MilskoLLDestroy(HMILSKOLL handle) {
XFreeGC(handle->display, handle->gc); XFreeGC(handle->display, handle->gc);
XDestroyWindow(handle->display, handle->window); XDestroyWindow(handle->display, handle->window);
free(handle); free(handle);
} }
void MilskoLLPolygon(HMILSKO handle, MilskoPoint* points, int points_count, HMILSKOCOLOR color) { void MilskoLLPolygon(HMILSKOLL handle, MilskoPoint* points, int points_count, HMILSKOCOLOR color) {
int i; int i;
XPoint* p = malloc(sizeof(*p) * points_count); XPoint* p = malloc(sizeof(*p) * points_count);
@@ -53,7 +51,7 @@ void MilskoLLPolygon(HMILSKO handle, MilskoPoint* points, int points_count, HMIL
free(p); free(p);
} }
HMILSKOCOLOR MilskoLLAllocColor(HMILSKO handle, int r, int g, int b) { HMILSKOCOLOR MilskoLLAllocColor(HMILSKOLL handle, int r, int g, int b) {
HMILSKOCOLOR c = malloc(sizeof(*c)); HMILSKOCOLOR c = malloc(sizeof(*c));
XColor xc; XColor xc;
xc.red = 256 * r; xc.red = 256 * r;
@@ -65,7 +63,7 @@ HMILSKOCOLOR MilskoLLAllocColor(HMILSKO handle, int r, int g, int b) {
return c; return c;
} }
void MilskoLLGetXYWH(HMILSKO handle, int* x, int* y, unsigned int* w, unsigned int* h) { void MilskoLLGetXYWH(HMILSKOLL handle, int* x, int* y, unsigned int* w, unsigned int* h) {
*x = handle->x; *x = handle->x;
*y = handle->y; *y = handle->y;
*w = handle->width; *w = handle->width;
@@ -76,7 +74,7 @@ void MilskoLLFreeColor(HMILSKOCOLOR color) {
free(color); free(color);
} }
int MilskoLLPending(HMILSKO handle) { int MilskoLLPending(HMILSKOLL handle) {
XEvent ev; XEvent ev;
if(XCheckWindowEvent(handle->display, handle->window, mask, &ev)) { if(XCheckWindowEvent(handle->display, handle->window, mask, &ev)) {
XPutBackEvent(handle->display, &ev); XPutBackEvent(handle->display, &ev);
@@ -85,7 +83,7 @@ int MilskoLLPending(HMILSKO handle) {
return 0; return 0;
} }
void MilskoLLNextEvent(HMILSKO handle) { void MilskoLLNextEvent(HMILSKOLL handle) {
XEvent ev; XEvent ev;
if(XCheckWindowEvent(handle->display, handle->window, mask, &ev)) { if(XCheckWindowEvent(handle->display, handle->window, mask, &ev)) {
} }