From c58751af3206a1fe5eccfbd40571cb2abc7f9ccf Mon Sep 17 00:00:00 2001 From: Dejan Lekic Date: Fri, 21 Dec 2018 16:40:42 +0000 Subject: [PATCH 1/6] help() moved to xterm where it belongs. --- src/med/console.d | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/med/console.d b/src/med/console.d index 7f67b4a..ee0e78b 100644 --- a/src/med/console.d +++ b/src/med/console.d @@ -14,23 +14,21 @@ module console; -version (Windows) -{ - import std.stdio; import core.stdc.stdlib; import core.stdc.string; -import core.sys.windows.windows; -import core.sys.windows.winuser; import ed; import disp; +version (Windows) +{ +import core.sys.windows.windows; +import core.sys.windows.winuser; enum BEL = 0x07; /* BEL character. */ enum ESC = 0x1B; /* ESC character. */ - static HANDLE hStdin; // console input handle static DWORD fdwSaveOldMode; @@ -487,5 +485,4 @@ int help(bool f, int n) return ed.FALSE; } -} - +} // Windows version From 89c3cdc95b626ac0c26f0586a32cbc814690b59e Mon Sep 17 00:00:00 2001 From: Dejan Lekic Date: Fri, 21 Dec 2018 16:41:26 +0000 Subject: [PATCH 2/6] Implemented the help() for the Posix systems, and fixed the int - ulong (size_t) problem in the display module. --- linux.mak | 3 +++ src/med/display.d | 8 +++++--- src/med/main.d | 1 + src/med/url.d | 1 + src/med/utf.d | 2 +- src/med/xterm.d | 10 ++++++++++ 6 files changed, 21 insertions(+), 4 deletions(-) diff --git a/linux.mak b/linux.mak index 7698391..41284c7 100644 --- a/linux.mak +++ b/linux.mak @@ -86,6 +86,9 @@ $O/termio.o: $S/termio.d $O/url.o: $S/url.d $(DMD) -c $(DFLAGS) $S/url.d +$O/utf.o: $S/utf.d + $(DMD) -c $(DFLAGS) $S/utf.d + $O/window.o: $S/window.d $(DMD) -c $(DFLAGS) $S/window.d diff --git a/src/med/display.d b/src/med/display.d index a930e09..d2d1b0f 100644 --- a/src/med/display.d +++ b/src/med/display.d @@ -318,13 +318,15 @@ int coltodoto(LINE* lp, int col) { size_t len = llength(lp); size_t i = 0; + int ii = 0; while (i < len) { - if (getcol(lp,i) >= col) - return i; + ii = cast(int) i; + if (getcol(lp, ii) >= col) + return ii; decodeUTF8(lp.l_text, i); } - return i; + return ii; } /*********************** diff --git a/src/med/main.d b/src/med/main.d index 8d5481a..0dffac7 100644 --- a/src/med/main.d +++ b/src/med/main.d @@ -56,6 +56,7 @@ import display; import terminal; import line; import mouse; +import console; // help int currow; /* Working cursor row */ int fillcol; /* Current fill column */ diff --git a/src/med/url.d b/src/med/url.d index 5c02c0b..7aaf951 100644 --- a/src/med/url.d +++ b/src/med/url.d @@ -1,3 +1,4 @@ +module url; import core.stdc.stdio; import core.stdc.ctype; diff --git a/src/med/utf.d b/src/med/utf.d index 3c30f5d..aaeb115 100644 --- a/src/med/utf.d +++ b/src/med/utf.d @@ -1,4 +1,4 @@ - +module utf; /* This version of microEmacs is based on the public domain C * version written by Dave G. Conroy. diff --git a/src/med/xterm.d b/src/med/xterm.d index 86b739d..9c9704f 100644 --- a/src/med/xterm.d +++ b/src/med/xterm.d @@ -596,4 +596,14 @@ debug } } +import std.process: spawnProcess; + +int help(bool f, int n) +{ + printf("\nhelp \n"); + auto dmdPid = spawnProcess(["xdg-open", "me.html"]); + + return ed.FALSE; } + +} // Posix version From e04fe601cffb39276e7530e215f6329f46ca0c1b Mon Sep 17 00:00:00 2001 From: Dejan Lekic Date: Fri, 21 Dec 2018 17:36:51 +0000 Subject: [PATCH 3/6] Now it finally builds --- linux.mak | 9 ++++++--- src/med/display.d | 2 +- src/med/line.d | 8 ++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/linux.mak b/linux.mak index 41284c7..127865d 100644 --- a/linux.mak +++ b/linux.mak @@ -18,17 +18,17 @@ LDFLG=-g \ all: $B/med SRC= $S/ed.d $S/basic.d $S/buffer.d $S/display.d $S/file.d $S/fileio.d $S/line.d \ - $S/random.d $S/region.d $S/search.d $S/spawn.d $S/terminal.d \ + $S/random.d $S/region.d $S/search.d $S/spawn.d $S/syntaxd.d $S/terminal.d \ $S/window.d $S/word.d $S/main.d $S/more.d $S/disprev.d \ $S/termio.d $S/xterm.d \ $S/tcap.d $S/console.d $S/mouse.d $S/disp.d $S/url.d $S/utf.d OBJ= $O/ed.o $O/basic.o $O/buffer.o $O/display.o $O/file.o $O/fileio.o $O/line.o \ - $O/random.o $O/region.o $O/search.o $O/spawn.o $O/terminal.o \ + $O/random.o $O/region.o $O/search.o $O/spawn.o $O/syntaxd.o $O/terminal.o \ $O/window.o $O/word.o $O/main.o $O/more.o $O/disprev.o \ $O/termio.o $O/xterm.o \ - $O/tcap.o $O/console.o $O/mouse.o $O/disp.o $O/url.o $O/utf.d + $O/tcap.o $O/console.o $O/mouse.o $O/disp.o $O/url.o $O/utf.o SOURCE= $(SRC) win32.mak linux.mak me.html @@ -77,6 +77,9 @@ $O/search.o: $S/search.d $O/spawn.o: $S/spawn.d $(DMD) -c $(DFLAGS) $S/spawn.d +$O/syntaxd.o: $S/syntaxd.d + $(DMD) -c $(DFLAGS) $S/syntaxd.d + $O/terminal.o: $S/terminal.d $(DMD) -c $(DFLAGS) $S/terminal.d diff --git a/src/med/display.d b/src/med/display.d index d2d1b0f..69505a3 100644 --- a/src/med/display.d +++ b/src/med/display.d @@ -544,7 +544,7 @@ Lout: assert(p); lineAttr = p[0 .. newlen]; } - const nextState = syntaxHighlightD(lp.syntaxState, lp.l_text, lineAttr); + const nextState = syntaxHighlightD(lp.syntaxState, lp.l_text, lineAttr); auto lpn = lforw(lp); if (lpn != wp.w_bufp.b_linep) /* if not end of buffer */ { diff --git a/src/med/line.d b/src/med/line.d index 9e5a614..39c5489 100644 --- a/src/med/line.d +++ b/src/med/line.d @@ -42,10 +42,10 @@ import random; * additions will include update hints, and a list of marks into the line. */ struct LINE { - LINE *l_fp; /* Link to the next line */ - LINE *l_bp; /* Link to the previous line */ - SyntaxState syntaxState; // state at the beginning of the line - char[] l_text; /* A bunch of characters. */ + LINE *l_fp; /* Link to the next line */ + LINE *l_bp; /* Link to the previous line */ + SyntaxState syntaxState; /* state at the beginning of the line */ + char[] l_text; /* A bunch of characters. */ } LINE* lforw(LINE* lp) { return lp.l_fp; } From b340dea390230b03f0e357fc8d4040f36c2f3d9d Mon Sep 17 00:00:00 2001 From: Dejan Lekic Date: Fri, 21 Dec 2018 18:03:38 +0000 Subject: [PATCH 4/6] Revert "fix erase to end of line bug" This reverts commit ca82ec4f1d5a89f1d13844bd901dbc8b844a3172. --- src/med/display.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/med/display.d b/src/med/display.d index d2d1b0f..d62e603 100644 --- a/src/med/display.d +++ b/src/med/display.d @@ -593,12 +593,12 @@ Lout: } if (inmark == 2) inmark = 0; + if (!nextLine) + break; lp = lforw(lp); } vteeol(wp.w_startcol); ++i; - if (!nextLine) - break; } } debug (WFDEBUG) From 08cfbaf351d2ca1c2312cff3d4edd3e07fa60723 Mon Sep 17 00:00:00 2001 From: Dejan Lekic Date: Fri, 21 Dec 2018 19:02:52 +0000 Subject: [PATCH 5/6] Cleanup --- src/med/console.d | 11 +++++------ src/med/main.d | 1 - 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/med/console.d b/src/med/console.d index ee0e78b..246a069 100644 --- a/src/med/console.d +++ b/src/med/console.d @@ -14,17 +14,16 @@ module console; -import std.stdio; -import core.stdc.stdlib; -import core.stdc.string; - -import ed; -import disp; version (Windows) { +import std.stdio; +import core.stdc.stdlib; +import core.stdc.string; import core.sys.windows.windows; import core.sys.windows.winuser; +import ed; +import disp; enum BEL = 0x07; /* BEL character. */ enum ESC = 0x1B; /* ESC character. */ diff --git a/src/med/main.d b/src/med/main.d index 0dffac7..8d5481a 100644 --- a/src/med/main.d +++ b/src/med/main.d @@ -56,7 +56,6 @@ import display; import terminal; import line; import mouse; -import console; // help int currow; /* Working cursor row */ int fillcol; /* Current fill column */ From adaa2d7cb786cf470715b017d72a7611d58d1a08 Mon Sep 17 00:00:00 2001 From: Dejan Lekic Date: Fri, 21 Dec 2018 19:16:13 +0000 Subject: [PATCH 6/6] space before tab fix --- src/med/display.d | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/med/display.d b/src/med/display.d index 25b6816..0f1a008 100644 --- a/src/med/display.d +++ b/src/med/display.d @@ -318,15 +318,15 @@ int coltodoto(LINE* lp, int col) { size_t len = llength(lp); size_t i = 0; - int ii = 0; + int ii = 0; while (i < len) { ii = cast(int) i; if (getcol(lp, ii) >= col) - return ii; + return ii; decodeUTF8(lp.l_text, i); } - return ii; + return ii; } /***********************