mirror of https://github.com/buggins/dlangui.git
remove usage of std.stream since it's deprecated; fix build warnings on new DMD
This commit is contained in:
parent
a6a818a884
commit
cde32bf2f3
|
@ -383,6 +383,7 @@
|
|||
<File path="src\dlangui\core\settings.d" />
|
||||
<File path="src\dlangui\core\signals.d" />
|
||||
<File path="src\dlangui\core\stdaction.d" />
|
||||
<File path="src\dlangui\core\streams.d" />
|
||||
<File path="src\dlangui\core\textsource.d" />
|
||||
<File path="src\dlangui\core\types.d" />
|
||||
</Folder>
|
||||
|
@ -398,16 +399,16 @@
|
|||
<File path="src\dlangui\dml\parser.d" />
|
||||
</Folder>
|
||||
<Folder name="graphics">
|
||||
<Folder name="xpm">
|
||||
<File path="src\dlangui\graphics\xpm\colors.d" />
|
||||
<File path="src\dlangui\graphics\xpm\reader.d" />
|
||||
</Folder>
|
||||
<Folder name="scene">
|
||||
<File path="src\dlangui\graphics\scene\camera.d" />
|
||||
<File path="src\dlangui\graphics\scene\node.d" />
|
||||
<File path="src\dlangui\graphics\scene\scene3d.d" />
|
||||
<File path="src\dlangui\graphics\scene\transform.d" />
|
||||
</Folder>
|
||||
<Folder name="xpm">
|
||||
<File path="src\dlangui\graphics\xpm\colors.d" />
|
||||
<File path="src\dlangui\graphics\xpm\reader.d" />
|
||||
</Folder>
|
||||
<File path="src\dlangui\graphics\colors.d" />
|
||||
<File path="src\dlangui\graphics\drawbuf.d" />
|
||||
<File path="src\dlangui\graphics\fonts.d" />
|
||||
|
|
|
@ -21,8 +21,8 @@ import dlangui.core.logger;
|
|||
import dlangui.core.signals;
|
||||
import dlangui.core.collections;
|
||||
import dlangui.core.linestream;
|
||||
import dlangui.core.streams;
|
||||
import std.algorithm;
|
||||
import std.stream;
|
||||
import std.conv : to;
|
||||
|
||||
// uncomment FileFormats debug symbol to dump file formats for loaded/saved files.
|
||||
|
@ -1379,7 +1379,7 @@ class EditableContent {
|
|||
bool load(string filename) {
|
||||
clear();
|
||||
try {
|
||||
std.stream.File f = new std.stream.File(filename);
|
||||
InputStream f = new FileInputStream(filename);
|
||||
scope(exit) { f.close(); }
|
||||
return load(f, filename);
|
||||
} catch (Exception e) {
|
||||
|
@ -1418,7 +1418,7 @@ class EditableContent {
|
|||
if (!filename)
|
||||
filename = _filename;
|
||||
try {
|
||||
std.stream.File f = new std.stream.File(filename, FileMode.OutNew);
|
||||
OutputStream f = new FileOutputStream(filename);
|
||||
scope(exit) { f.close(); }
|
||||
return save(f, filename, format);
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -514,7 +514,7 @@ struct ButtonDetails {
|
|||
return _doubleClick;
|
||||
}
|
||||
|
||||
static final long DOUBLE_CLICK_THRESHOLD_MS = 200;
|
||||
static long DOUBLE_CLICK_THRESHOLD_MS = 200;
|
||||
|
||||
|
||||
void reset() {
|
||||
|
|
|
@ -50,7 +50,8 @@ Authors: Vadim Lopatin, coolreader.org@gmail.com
|
|||
*/
|
||||
module dlangui.core.linestream;
|
||||
|
||||
import std.stream;
|
||||
import dlangui.core.streams;
|
||||
//import std.stream;
|
||||
import std.stdio;
|
||||
import std.conv;
|
||||
import std.utf;
|
||||
|
@ -128,7 +129,7 @@ class OutputLineStream {
|
|||
|
||||
protected void flush() {
|
||||
if (_len > 0) {
|
||||
_stream.writeExact(_buf.ptr, _len);
|
||||
_stream.write(cast(ubyte[])_buf[0 .. _len]);
|
||||
_len = 0;
|
||||
}
|
||||
}
|
||||
|
@ -483,7 +484,7 @@ class LineStream {
|
|||
data[0] = 0xEF;
|
||||
data[1] = 0xBB;
|
||||
data[2] = 0xBF;
|
||||
MemoryStream stream = new MemoryStream(data);
|
||||
InputStream stream = new MemoryInputStream(data); //new MemoryStream(data);
|
||||
return create(stream, filename);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ Authors: Vadim Lopatin, coolreader.org@gmail.com
|
|||
module dlangui.core.logger;
|
||||
|
||||
import std.stdio;
|
||||
import std.datetime;
|
||||
import std.datetime : SysTime, Clock;
|
||||
|
||||
/// Log levels
|
||||
enum LogLevel : int {
|
||||
|
@ -117,7 +117,7 @@ synchronized class Log {
|
|||
void log(S...)(LogLevel level, S args) {
|
||||
if (logLevel >= level && logFile.isOpen) {
|
||||
SysTime ts = Clock.currTime();
|
||||
logFile.writef("%04d-%02d-%02d %02d:%02d:%02d.%03d %s ", ts.year, ts.month, ts.day, ts.hour, ts.minute, ts.second, ts.fracSec.msecs, logLevelName(level));
|
||||
logFile.writef("%04d-%02d-%02d %02d:%02d:%02d.%03d %s ", ts.year, ts.month, ts.day, ts.hour, ts.minute, ts.second, ts.fracSecs.split!("msecs").msecs, logLevelName(level));
|
||||
logFile.writeln(args);
|
||||
logFile.flush();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
module dlangui.core.streams;
|
||||
|
||||
private import std.stdio;
|
||||
|
||||
interface Closeable {
|
||||
void close();
|
||||
@property bool isOpen();
|
||||
}
|
||||
|
||||
interface InputStream : Closeable {
|
||||
size_t read(ubyte[] buffer);
|
||||
@property bool eof();
|
||||
}
|
||||
|
||||
interface OutputStream : Closeable {
|
||||
void write(ubyte[] data);
|
||||
}
|
||||
|
||||
class FileInputStream : InputStream {
|
||||
std.stdio.File _file;
|
||||
this(string filename) {
|
||||
_file = std.stdio.File(filename, "rb");
|
||||
}
|
||||
void close() {
|
||||
_file.close();
|
||||
}
|
||||
size_t read(ubyte[] buffer) {
|
||||
ubyte[] res = _file.rawRead(buffer);
|
||||
return res.length;
|
||||
}
|
||||
@property bool isOpen() {
|
||||
return _file.isOpen;
|
||||
}
|
||||
@property bool eof() {
|
||||
return _file.eof;
|
||||
}
|
||||
}
|
||||
|
||||
class FileOutputStream : OutputStream {
|
||||
std.stdio.File _file;
|
||||
this(string filename) {
|
||||
_file = std.stdio.File(filename, "wb");
|
||||
}
|
||||
void close() {
|
||||
_file.close();
|
||||
}
|
||||
void write(ubyte[] data) {
|
||||
_file.rawWrite(data);
|
||||
}
|
||||
@property bool isOpen() {
|
||||
return _file.isOpen;
|
||||
}
|
||||
}
|
||||
|
||||
class MemoryInputStream : InputStream {
|
||||
private ubyte[] _data;
|
||||
private size_t _pos;
|
||||
private bool _closed;
|
||||
this(ubyte[] data) {
|
||||
_data = data;
|
||||
_closed = false;
|
||||
_pos = 0;
|
||||
}
|
||||
void close() {
|
||||
_closed = true;
|
||||
}
|
||||
@property bool isOpen() {
|
||||
return !_closed;
|
||||
}
|
||||
size_t read(ubyte[] buffer) {
|
||||
size_t bytesRead = 0;
|
||||
for (size_t i = 0; i < buffer.length && _pos < _data.length; bytesRead++) {
|
||||
buffer[i++] = _data[_pos++];
|
||||
}
|
||||
return bytesRead;
|
||||
}
|
||||
@property bool eof() {
|
||||
return _closed || (_pos >= _data.length);
|
||||
}
|
||||
}
|
|
@ -40,7 +40,7 @@ import dlangui.core.logger;
|
|||
import dlangui.core.types;
|
||||
import dlangui.graphics.colors;
|
||||
import dlangui.graphics.drawbuf;
|
||||
import std.stream;
|
||||
import dlangui.core.streams;
|
||||
import std.path;
|
||||
import std.conv : to;
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ import dlangui.graphics.colors;
|
|||
public import dlangui.core.editable;
|
||||
|
||||
import std.algorithm;
|
||||
import std.stream;
|
||||
import dlangui.core.streams;
|
||||
|
||||
/// Modified state change listener
|
||||
interface ModifiedStateListener {
|
||||
|
|
Loading…
Reference in New Issue