Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions demos/colors/source/colors.d
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ColorBoxes
bool done;
Screen s;

bool flip()
bool flip() @safe
{
return (rng.uniform!ubyte() & 0x1) != 0;
}
Expand All @@ -50,7 +50,7 @@ class ColorBoxes
s = scr;
}

void makeBox()
void makeBox() @safe
{
Coord wsz = s.size();
dchar dc = ' ';
Expand Down Expand Up @@ -122,7 +122,7 @@ class ColorBoxes
s.show();
}

void handleEvent(Event ev)
void handleEvent(Event ev) @safe
{
switch (ev.type)
{
Expand Down Expand Up @@ -156,7 +156,7 @@ class ColorBoxes
}
}

void run()
void run() @safe
{
s.start();
scope (exit)
Expand Down
20 changes: 10 additions & 10 deletions demos/hello/dub.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"copyright": "Copyright 2022 Garrett D'Amore",
"description": "Hello World in Dcell",
"name": "hello",
"targetType": "executable",
"targetName": "hello",
"targetPath": "bin",
"mainSourceFile": "source/hello.d",
"dependencies": {
"dcell" : { "path": "../.." }
}
"copyright": "Copyright 2025 Garrett D'Amore",
"description": "Hello World in Dcell",
"name": "hello",
"targetType": "executable",
"targetName": "hello",
"targetPath": "bin",
"mainSourceFile": "source/hello.d",
"dependencies": {
"dcell": { "path": "../.." }
}
}
20 changes: 10 additions & 10 deletions demos/mouse/dub.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"copyright": "Copyright 2022 Garrett D'Amore",
"description": "Mouse demo in Dcell",
"name": "mouse",
"targetType": "executable",
"targetName": "mouse",
"targetPath": "bin",
"mainSourceFile": "source/mouse.d",
"dependencies": {
"dcell" : { "path": "../../" }
}
"copyright": "Copyright 2025 Garrett D'Amore",
"description": "Mouse demo in Dcell",
"name": "mouse",
"targetType": "executable",
"targetName": "mouse",
"targetPath": "bin",
"mainSourceFile": "source/mouse.d",
"dependencies": {
"dcell": { "path": "../../" }
}
}
2 changes: 1 addition & 1 deletion source/dcell/common.d
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Common module for dcell, it contains some package wide definitions.
*
* Copyright: Copyright 2022 Garrett D'Amore
* Copyright: Copyright 2025 Garrett D'Amore
* Authors: Garrett D'Amore
* License:
* Distributed under the Boost Software License, Version 1.0.
Expand Down
2 changes: 1 addition & 1 deletion source/dcell/cursor.d
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Cursor module for dcell.
*
* Copyright: Copyright 2022 Garrett D'Amore
* Copyright: Copyright 2025 Garrett D'Amore
* Authors: Garrett D'Amore
* License:
* Distributed under the Boost Software License, Version 1.0.
Expand Down
2 changes: 1 addition & 1 deletion source/dcell/event.d
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ struct FocusEvent
class EventQ
{

void put(Event ev)
void put(Event ev) @safe nothrow
{
events ~= ev;
}
Expand Down
42 changes: 14 additions & 28 deletions source/dcell/parser.d
Original file line number Diff line number Diff line change
Expand Up @@ -310,22 +310,22 @@ immutable KeyCode[int] winKeys = [
class Parser
{

Event[] events() pure
Event[] events() pure @safe @nogc
{
auto res = evs;
evs = null;
return cast(Event[]) res;
}

// Parse the supplied content, returns true if data is fully parsed.
bool parse(string b)
bool parse(string b) @safe
{
buf ~= b;
scan();
return parseState == ParseState.ini;
}

bool empty() const pure
bool empty() const pure @safe
{
return buf.length == 0;
}
Expand Down Expand Up @@ -368,7 +368,7 @@ private:
bool pasting;
dstring pasteBuf;

void postKey(Key k, dchar dch, Modifiers mod)
void postKey(Key k, dchar dch, Modifiers mod) nothrow @safe
{
if (pasting)
{
Expand All @@ -383,7 +383,7 @@ private:
}
}

void scan()
void scan() @trusted
{
while (!buf.empty)
{
Expand Down Expand Up @@ -674,7 +674,7 @@ private:
parseState = ParseState.ini;
}

void handleCsi(ubyte mode, string params, string interm)
void handleCsi(ubyte mode, string params, string interm) @safe
{
parseState = ParseState.ini;

Expand Down Expand Up @@ -865,7 +865,7 @@ private:
}
}

void handleMouse(ubyte mode, int p0, int p1, int p2)
void handleMouse(ubyte mode, int p0, int p1, int p2) nothrow @safe
{
// XTerm mouse events only report at most one button at a time,
// which may include a wheel button. Wheel motion events are
Expand Down Expand Up @@ -954,7 +954,7 @@ private:
evs ~= newMouseEvent(x, y, button, mod);
}

void handleWinKey(int p0, int p1, int p2, int p3, int p4, int p5)
void handleWinKey(int p0, int p1, int p2, int p3, int p4, int p5) @safe
{
// win32-input-mode
// ^[ [ Vk ; Sc ; Uc ; Kd ; Cs ; Rc _
Expand Down Expand Up @@ -1056,7 +1056,7 @@ private:
}

// calculate the modifiers from the CSI modifier parameter.
Modifiers calcModifier(int n)
Modifiers calcModifier(int n) pure nothrow @safe @nogc
{
n--;
Modifiers m;
Expand Down Expand Up @@ -1091,7 +1091,7 @@ private:
return m;
}

Event newFocusEvent(bool focused)
Event newFocusEvent(bool focused) nothrow @safe
{
Event ev =
{
Expand All @@ -1102,7 +1102,7 @@ private:
return ev;
}

Event newKeyEvent(Key k, dchar dch = 0, Modifiers mod = Modifiers.none)
Event newKeyEvent(Key k, dchar dch = 0, Modifiers mod = Modifiers.none) nothrow @safe
{
if (escaped)
{
Expand Down Expand Up @@ -1147,7 +1147,7 @@ private:
return ev;
}

Event newMouseEvent(int x, int y, Buttons btn, Modifiers mod)
Event newMouseEvent(int x, int y, Buttons btn, Modifiers mod) nothrow @safe
{
Event ev = {
type: EventType.mouse, when: MonoTime.currTime, mouse: {
Expand All @@ -1162,7 +1162,7 @@ private:
// NB: it is possible for x and y to be outside the current coordinates
// (happens for click drag for example). Consumer of the event should clip
// the coordinates as needed.
Event newMouseEvent(int x, int y, int btn)
Event newMouseEvent(int x, int y, int btn) nothrow @safe
{
Event ev = {
type: EventType.mouse, when: MonoTime.currTime, mouse: {
Expand Down Expand Up @@ -1207,7 +1207,7 @@ private:
return ev;
}

Event newPasteEvent(dstring buffer)
Event newPasteEvent(dstring buffer) nothrow @safe
{
Event ev = {
type: EventType.paste, when: MonoTime.currTime(), paste: {
Expand All @@ -1217,20 +1217,6 @@ private:
return ev;
}

bool parseSequence(string seq)
{
if (startsWith(buf, seq))
{
buf = buf[seq.length .. $]; // yank the sequence
return true;
}
if (startsWith(seq, buf))
{
partial = true;
}
return false;
}

unittest
{
import core.thread;
Expand Down
Loading