-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWintext.bat
704 lines (636 loc) · 21.5 KB
/
Wintext.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
@echo off
setlocal DISABLEDELAYEDEXPANSION
set undo=0
set deleted=0
set newline=0
set typefile=0
set typefileonce=0
set splitfile=0
set splitfileonce=0
set commandsoff=0
set exit=0
set dir=
set filename=
set wintext=wintext
set WinTXT=WinTXT
set input=0
set arg1="%1"
set arg2="%2"
set arg3="%3"
set arg4="%4"
(echo "%arg1%" | findstr /i /c:"-?" >nul ) && (goto :helparg1) || (echo. > nul)
(echo "%arg2%" | findstr /i /c:"-?" >nul ) && (goto :helparg2) || (echo. > nul)
(echo "%arg3%" | findstr /i /c:"-?" >nul ) && (goto :helparg3) || (echo. > nul)
(echo "%arg1%" | findstr /i /c:"/h" >nul ) && (goto :help2arg1) || (echo. > nul)
(echo "%arg1%" | findstr /i /c:"/n" >nul ) && (goto :namearg1) || (echo. > nul)
(echo "%arg2%" | findstr /i /c:"/n" >nul ) && (goto :namearg2) || (echo. > nul)
(echo "%arg3%" | findstr /i /c:"/n" >nul ) && (goto :namearg3) || (echo. > nul)
set baseline=""
if "%arg1%"=="%baseline%" goto :beginning
set input=1
goto :fileopen
:helparg1
goto :commandlinehelp
:helparg2
set arg1=%arg2%
goto :commandlinehelp
:helparg3
set arg1=%arg3%
goto :commandlinehelp
:help2arg1
set wintext=%arg1%
for /f "useback tokens=*" %%a in ('%wintext%') do set wintext=%%~a
for /f "useback tokens=*" %%a in ('%wintext%') do set wintext=%%~a
for /f "useback tokens=*" %%a in ('%wintext%') do set wintext=%%~a
for /f "useback tokens=*" %%a in ('%wintext%') do set wintext=%%~a
set wintext=%wintext:~-4%
goto :commandlinehelp
:namearg1
set WinTXT=%arg2%
for /f "useback tokens=*" %%a in ('%WinTXT%') do set WinTXT=%%~a
for /f "useback tokens=*" %%a in ('%WinTXT%') do set WinTXT=%%~a
title %WinTXT%
goto :beginning
:namearg2
set WinTXT=%arg3%
for /f "useback tokens=*" %%a in ('%WinTXT%') do set WinTXT=%%~a
for /f "useback tokens=*" %%a in ('%WinTXT%') do set WinTXT=%%~a
title %WinTXT%
set baseline=""
if "%arg1%"=="%baseline%" goto :beginning
set input=1
goto :fileopen
:namearg3
set WinTXT=%arg4%
for /f "useback tokens=*" %%a in ('%WinTXT%') do set WinTXT=%%~a
for /f "useback tokens=*" %%a in ('%WinTXT%') do set WinTXT=%%~a
title %WinTXT%
set baseline=""
if "%arg1%"=="%baseline%" goto :beginning
if "%arg2%"=="%baseline%" goto :beginning
set input=1
goto :fileopen
:beginning
title %WinTXT%
if exist C:\Temp\DocTemp\unsaved goto :recoverstart
cls
echo Welcome to %WinTXT%, A Command Line Editor For Windows!!
echo This program was made by Logan C.
pause
:start
setlocal ENABLEDELAYEDEXPANSION
cls
echo What would you like to name your file (and be sure to add a file extension)?
set /p filename="Enter Filename: "
if exist %filename% goto :skip
cls
echo Where would you like to place your file? (Default is (your user directory)\%WinTXT%Docs)
set /p dir="Enter Directory: "
if not defined dir set dir=%userprofile%\%WinTXT%Docs\
set dirend=%dir:~-1%
if not "%dirend%"=="\" set dir=%dir%\
cls
if not exist "%dir%" mkdir "%dir%
if exist "%dir%%filename%" (
if not exist C:\Temp\DocTemp\ mkdir C:\Temp\DocTemp\
copy "%dir%%filename%" C:\Temp\DocTemp\doctemp.txt
) else (
del C:\Temp\DocTemp\doctemp.txt
)
echo. >> "C:\Temp\DocTemp\doctemp.txt"
call :SPLIT
setlocal ENABLEDELAYEDEXPANSION
del C:\Temp\DocTemp\temp.txt 2> nul
set /p fcount2= < "C:\Temp\DocTemp\doctemp.txtfcount" 2> nul
del "C:\Temp\DocTemp\doctemp.txtfcount" 2> nul
set lcount=2000000000
goto :textadd
:SPLIT
SETLOCAL DISABLEDELAYEDEXPANSION
if not exist C:\Temp\DocTemp\ mkdir C:\Temp\DocTemp\
copy "C:\Temp\DocTemp\doctemp.txt" C:\Temp\DocTemp\temp.txt > nul
SET /a fcount=1999999999
SET /a llimit=1
SET /a lcount=%llimit%
FOR /f "usebackqdelims=" %%a IN (C:\Temp\DocTemp\temp.txt) DO (
CALL :select
>>"C:\Temp\DocTemp\temp.txt$$" ECHO(%%a
)
SET /a lcount=%llimit%
:select
SET /a lcount+=1
IF %lcount% lss %llimit% GOTO :EOF >NUL 2>nul
SET /a lcount=0
SET /a fcount+=1
MOVE /y "C:\Temp\DocTemp\temp.txt$$" "C:\Temp\DocTemp\doctemp.txtline%fcount:~-9%" >NUL 2>nul
attrib +h "C:\Temp\DocTemp\doctemp.txtline%fcount:~-9%" >NUL 2>nul
echo %fcount:~-9% > "C:\Temp\DocTemp\doctemp.txtfcount"
GOTO :EOF
:textadd
setlocal ENABLEDELAYEDEXPANSION
if %exit% equ 1 (
exit /b )
if not exist C:\Temp\DocTemp\ mkdir C:\Temp\DocTemp\
set display=%dir%%filename%
for /f "useback tokens=*" %%a in ('%display%') do set display=%%~a
for /f "useback tokens=*" %%a in ('%display%') do set display=%%~a
for /f "useback tokens=*" %%a in ('%display%') do set display=%%~a
for /f "useback tokens=*" %%a in ('%display%') do set display=%%~a
set newline=0
set /a undo+=1
cls
if %undo% geq 11 set undo=1
call :wintxtdisplay
echo =====Current Undo State is: %undo%=====
echo =====%display%=====
if %commandsoff% equ 1 call :commandsoffwarning
echo.
if %deleted% equ 1 (
set deleted=0
goto :edit
)
set lcount=2000000000
:linebyline
set /a lcount+=1
set /p line=<"C:\Temp\DocTemp\doctemp.txtline%lcount:~-9%" 2> nul
set /a lcount1=%lcount%-2000000000
echo Line: %lcount1% : !line!
if %lcount:~-9% geq %fcount2% goto :edit
goto :linebyline
:edit
echo.
set text=
attrib -h "C:\Temp\DocTemp\doctemp.txt%undo%" > nul
copy /y "C:\Temp\DocTemp\doctemp.txt" "C:\Temp\DocTemp\doctemp.txt%undo%" > nul 2>nul
attrib +h "C:\Temp\DocTemp\doctemp.txt%undo%" > nul
set /p text="Type: " 2> nul
set baseline=
if "!text!"=="%baseline%" set text=/linebreak
set baseline=/?
if "!text!"=="%baseline%" set text=/help
set baseline=on
if "!text!"=="%baseline%" set text="on"
set baseline=off
if "!text!"=="%baseline%" set text="off"
if %commandsoff% equ 1 (
(echo "!text!" | findstr /i /c:"/commandson" >nul ) && (goto :commandson) || (echo. > nul )
(echo "!text!" | findstr /i /c:"/editline" >nul ) && (goto :line) || (echo. > nul )
(echo "!text!" | findstr /i /c:"/newline" >nul ) && (goto :newline) || (echo. > nul )
(echo "!text!" | findstr /i /c:"/delline" >nul ) && (goto :delline) || (echo. > nul )
goto :addtext
)
(echo "!text!" | findstr /i /c:"/undo" >nul ) && (goto :undo) || (echo. > nul )
(echo "!text!" | findstr /i /c:"/save" >nul ) && (call :save1 ) || (echo. > nul )
(echo "!text!" | findstr /i /c:"/redo" >nul ) && (goto :redo) || (echo. > nul )
(echo "!text!" | findstr /i /c:"/delfile" >nul ) && (goto :del) || (echo. > nul )
(echo "!text!" | findstr /i /c:"/editline" >nul ) && (goto :line) || (echo. > nul )
(echo "!text!" | findstr /i /c:"/newline" >nul ) && (goto :newline) || (echo. > nul )
(echo "!text!" | findstr /i /c:"/delline" >nul ) && (goto :delline) || (echo. > nul )
(echo "!text!" | findstr /i /c:"/linebreak" >nul ) && (goto :linebreak) || (echo. > nul )
(echo "!text!" | findstr /i /c:"/commandsoff" >nul ) && (goto :commandsoff) || (echo. > nul )
(echo "!text!" | findstr /i /c:"/exit" >nul ) && (goto :undoclear) || (echo. > nul )
(echo "!text!" | findstr /i /c:"/help" >nul ) && (goto :help) || (goto :addtext)
:addtext
set baseline=
echo !text! >> "C:\Temp\DocTemp\doctemp.txt" 2> nul
echo !text! > "C:\Temp\DocTemp\temp.txt" 2> nul
call :addline
set /p fcount2=< C:\Temp\DocTemp\fcount 2> nul
del C:\Temp\DocTemp\fcount > nul 2> nul
echo This File Exists^! > "C:\Temp\DocTemp\unsaved" 2 > nul
if not "%dir%"=="%baseline%" echo %dir%> "C:\Temp\DocTemp\dir" 2 > nul
echo %filename%> "C:\Temp\DocTemp\filename" 2 > nul
attrib -h "C:\Temp\DocTemp\undo" > nul 2> nul
echo %undo% > "C:\Temp\DocTemp\undo" > nul 2> nul
attrib +h "C:\Temp\DocTemp\unsaved" > nul 2> nul
attrib +h "C:\Temp\DocTemp\dir" > nul 2> nul
attrib +h "C:\Temp\DocTemp\filename" > nul 2> nul
attrib +h "C:\Temp\DocTemp\undo" > nul 2> nul
goto :textadd
:newline
set newline=1
goto :line
:delline
set text=%text:/delline =%
set lcount=2000000000
set /a lcount+=!text!
del /ah "C:\Temp\DocTemp\doctemp.txtline%lcount:~-9%"
goto :rebuild
:typefile
(echo "!text!" | findstr /i /c:"/typefileonce" >nul ) && (set typefileonce=1) || (echo. > nul )
if %typefileonce% equ 1 goto :textadd
set typefile=1
set splitfile=0
goto :textadd
:commandsoff
set commandsoff=1
goto :textadd
:commandson
set commandsoff=0
goto :textadd
:commandsoffwarning
setlocal DISABLEDELAYEDEXPANSION
echo !!===!!WARNING! COMMANDS ARE CURRENTLY OFF! TO RE-ENABLE COMMANDS, TYPE "/commandson" !!===!!
setlocal ENABLEDELAYEDEXPANSION
exit /b
:addline
setlocal DISABLEDELAYEDEXPANSION 2> nul
set /a lcount+=1
echo %lcount:~-9% > C:\Temp\DocTemp\fcount
attrib -h C:\Temp\DocTemp\doctemp.txtline%lcount:~-9% > nul 2> nul
copy C:\Temp\DocTemp\temp.txt C:\Temp\DocTemp\doctemp.txtline%lcount:~-9% > nul 2> nul
del C:\Temp\DocTemp\temp.txt > nul 2> nul
attrib +h C:\Temp\DocTemp\doctemp.txtline%lcount:~-9% 2> nul
setlocal ENABLEDELAYEDEXPANSION 2> nul
exit /b
:fileopen
set dir=
if %input% equ 0 (
set filename=%arg1%
)
if %input% equ 1 (
set filename=%arg1%
)
if %input% equ 2 (
set filename=%arg2%
)
if exist C:\Temp\DocTemp\unsaved goto :recover
if not exist C:\Temp\DocTemp\ mkdir C:\Temp\DocTemp\
del > C:\Temp\DocTemp\doctemp.txt
copy "%dir%%filename%" C:\Temp\DocTemp\doctemp.txt
echo. >> "C:\Temp\DocTemp\doctemp.txt"
call :SPLIT
setlocal ENABLEDELAYEDEXPANSION
del C:\Temp\DocTemp\temp.txt 2> nul
set /p fcount2= < "C:\Temp\DocTemp\doctemp.txtfcount" 2> nul
del "C:\Temp\DocTemp\doctemp.txtfcount" 2> nul
set lcount=2000000000
goto :textadd
:save1
call :save
goto :textadd
:wintxtdisplay
setlocal DISABLEDELAYEDEXPANSION
echo =====%WinTXT% -- A Command Line Editor For Windows=====
title %WinTXT% : %display%
setlocal ENABLEDELAYEDEXPANSION
exit /b
:skip
set %dir%=
if exist C:\Temp\DocTemp\unsaved goto :recover
if not exist C:\Temp\DocTemp\ mkdir C:\Temp\DocTemp\
del C:\Temp\DocTemp\doctemp.txt
copy "%dir%%filename%" C:\Temp\DocTemp\doctemp.txt
echo. >> "C:\Temp\DocTemp\doctemp.txt"
call :SPLIT
setlocal ENABLEDELAYEDEXPANSION
del C:\Temp\DocTemp\temp.txt 2> nul
set /p fcount2= < "C:\Temp\DocTemp\doctemp.txtfcount" 2> nul
del "C:\Temp\DocTemp\doctemp.txtfcount" 2> nul
set lcount=2000000000
goto :textadd
:commandlinehelp
echo Syntax: %wintext% (file) (flags)
echo Flags:
echo -? : This help screen.
echo It's not that hard!
echo v4.2 (i guess) copyright 2020 Logan C.
exit /b
:splitfile
set typefile=0
set splitfile=1
goto :textadd
:recover
echo Warning! %WinTXT% Has detected an unsaved file that was being edited.
choice /c yn /n /m "Would you like to attempt to recover? Y/N"
if %errorlevel% equ 1 (
set /p dir= < "C:\Temp\DocTemp\dir"
set /p filename= < "C:\Temp\DocTemp\filename"
set /p undo= < "C:\Temp\DocTemp\undo"
call :SPLIT
setlocal ENABLEDELAYEDEXPANSION
del C:\Temp\DocTemp\temp.txt 2> nul
set /p fcount2= < "C:\Temp\DocTemp\doctemp.txtfcount" 2> nul
del "C:\Temp\DocTemp\doctemp.txtfcount" 2> nul
set lcount=2000000000
goto :textadd
)
if %errorlevel% equ 2 (
del C:\Temp\DocTemp\doctemp.txt
del /ah /q C:\Temp\DocTemp\unsaved
del /ah /q C:\Temp\DocTemp\dir
del /ah /q C:\Temp\DocTemp\filename
if not exist C:\Temp\DocTemp\ mkdir C:\Temp\DocTemp\
copy "%dir%%filename%" C:\Temp\DocTemp\doctemp.txt
echo. >> "C:\Temp\DocTemp\doctemp.txt"
goto :textadd
)
goto :textadd
:recoverstart
echo WARNING! %WinTXT% Has detected a file was edited and not saved.
choice /c yn /n /m "Would you like to attempt to recover the file? Y/N"
if %errorlevel% equ 1 (
set /p dir= < "C:\Temp\DocTemp\dir"
set /p filename= < "C:\Temp\DocTemp\filename"
set /p undo= < "C:\Temp\DocTemp\undo"
call :SPLIT
setlocal ENABLEDELAYEDEXPANSION
del C:\Temp\DocTemp\temp.txt 2> nul
set /p fcount2= < "C:\Temp\DocTemp\doctemp.txtfcount" 2> nul
del "C:\Temp\DocTemp\doctemp.txtfcount" 2> nul
set lcount=2000000000
goto :textadd
)
if %errorlevel% equ 2 (
del /ah /q "C:\Temp\DocTemp\unsaved"
del /ah /q "C:\Temp\DocTemp\dir"
del /ah /q "C:\Temp\DocTemp\filename"
del /q "C:\Temp\DocTemp\doctemp.txt"
del /ah /q "C:\Temp\DocTemp\undo"
goto :beginning
)
:splitfileonce
set splitfileonce=1
set typefile=0
goto :textadd
:save
cls
choice /c yn /n /m "Are you sure you want to save your file Y/N?"
if %errorlevel% equ 1 (
copy C:\Temp\DocTemp\doctemp.txt "%dir%%filename%" 2> C:\Temp\DocTemp\output.txt
set /p output= < "C:\Temp\DocTemp\output.txt" 2> nul
del C:\Temp\DocTemp\output.txt 2> nul
del /ah /q C:\Temp\DocTemp\unsaved 2> nul
del /ah /q C:\Temp\DocTemp\dir 2> nul
del /ah /q C:\Temp\DocTemp\filename 2> nul
del /ah /q C:\Temp\DocTemp\undo 2> nul
echo This Document Was Written/Edited with %WinTXT% > "%dir%%filename%":shamelessplug
if %WinTXT% equ WinTXT (
echo %WinTXT% was made by Logan C. >> "%dir%%filename%":shamelessplug
) Else (
echo %WinTXT% is based on WinTXT, which was made by Logan C. >> "%dir%%filename%":shamelessplug
)
set baseline=
if not "!output!"=="!baseline!" (
echo The Following Error Occured:
echo !baseline! ) else (
echo File Saved.
)
pause
exit /b
)
if %errorlevel% equ 2 (
exit /b
)
:undo
if %undo% equ 1 set undo=11
set /a undo-=1 2> nul
type "C:\Temp\DocTemp\doctemp.txt%undo%" > "C:\Temp\DocTemp\doctemp.txt"
call :SPLIT
setlocal ENABLEDELAYEDEXPANSION
del C:\Temp\DocTemp\temp.txt 2> nul
set /p fcount2= < "C:\Temp\DocTemp\doctemp.txtfcount" 2> nul
del "C:\Temp\DocTemp\doctemp.txtfcount" 2> nul
set lcount=2000000000
set /a undo-=1 2> nul
goto :textadd
:redo
if %undo% equ 10 set undo=0
set /a undo+=1 2> nul
type "C:\Temp\DocTemp\doctemp.txt%undo%" > "C:\Temp\DocTemp\doctemp.txt"
call :SPLIT
setlocal ENABLEDELAYEDEXPANSION
del C:\Temp\DocTemp\temp.txt 2> nul
set /p fcount2= < "C:\Temp\DocTemp\doctemp.txtfcount" 2> nul
del "C:\Temp\DocTemp\doctemp.txtfcount" 2> nul
set lcount=2000000000
set /a undo-=1 2> nul
goto :textadd
:del
choice /c yn /n /m "Are you sure you want to delete your file Y/N?"
if %errorlevel% equ 1 (
del "%dir%%filename%"
del C:\Temp\DocTemp\doctemp.txt
call :SPLIT
setlocal ENABLEDELAYEDEXPANSION
del C:\Temp\DocTemp\temp.txt 2> nul
set /p fcount2= < "C:\Temp\DocTemp\doctemp.txtfcount" 2> nul
del "C:\Temp\DocTemp\doctemp.txtfcount" 2> nul
set lcount=2000000000
set deleted=1
goto :textadd
)
if %errorlevel% equ 2 (
goto :textadd
)
goto :textadd
:linebreak
echo. >> "C:\Temp\DocTemp\doctemp.txt"
echo. > "C:\Temp\DocTemp\temp.txt"
call :addline
set /p fcount2=< C:\Temp\DocTemp\fcount 2> nul
goto :textadd
:line
if %newline% equ 1 (
set text=%text:/newline =%
goto :linepart2
)
set text=%text:/editline =%
:linepart2
set lcount=2000000000
set /a lcount+=!text!
set /a lcount1=%lcount%-2000000000
set /a undo+=1
cls
if %undo% geq 11 set undo=1
call :wintxtdisplay
echo =====Current Undo State is: %undo%=====
set display=%dir%%filename%
for /f "useback tokens=*" %%a in ('%display%') do set display=%%~a
for /f "useback tokens=*" %%a in ('%display%') do set display=%%~a
for /f "useback tokens=*" %%a in ('%display%') do set display=%%~a
for /f "useback tokens=*" %%a in ('%display%') do set display=%%~a
echo =====%display%=====
echo =====Current Line Is: %lcount1%=====
if %commandsoff% equ 1 call :commandsoffwarning
if %newline% equ 1 goto :editline
set /p Line= <"C:\Temp\DocTemp\doctemp.txtline%lcount:~-9%"
echo.
echo Line: %lcount1% : !line!
echo.
echo.
:editline
set text=
attrib -h "C:\Temp\DocTemp\doctemp.txt%undo%" > nul
copy /y "C:\Temp\DocTemp\doctemp.txt" "C:\Temp\DocTemp\doctemp.txt%undo%" > nul 2>nul
attrib +h "C:\Temp\DocTemp\doctemp.txt%undo%" > nul
set /p text="Type: " 2> nul
set baseline=
if "!text!"=="%baseline%" set text=/linebreak
set baseline=/?
if "!text!"=="%baseline%" set text=/help
set baseline=on
if "!text!"=="%baseline%" set text="on"
set baseline=off
if "!text!"=="%baseline%" set text="off"
if %commandsoff% equ 1 (
(echo "!text!" | findstr /i /c:"/commandson" >nul ) && (goto :commandson) || (echo. > nul )
goto :addtextline
)
(echo "!text!" | findstr /i /c:"/undo" >nul ) && (goto :undo) || (echo. > nul )
(echo "!text!" | findstr /i /c:"/redo" >nul ) && (goto :redo) || (echo. > nul )
(echo "!text!" | findstr /i /c:"/delfile" >nul ) && (goto :del) || (echo. > nul )
(echo "!text!" | findstr /i /c:"/linebreak" >nul ) && (goto :linelinebreak) || (echo. > nul )
(echo "!text!" | findstr /i /c:"/typefile" >nul ) && (goto :typefile) || (echo. > nul )
(echo "!text!" | findstr /i /c:"/exit" >nul ) && (goto :undoclear) || (echo. > nul )
(echo "!text!" | findstr /i /c:"/help" >nul ) && (goto :help) || (echo. > nul)
(echo "!text!" | findstr /i /c:"/save" >nul ) && (call :save1) || (echo. > nul )
if %newline% equ 1 (
goto :addnewtextline
)
goto :addtextline
:addtextline
attrib -h "C:\Temp\DocTemp\doctemp.txtline%lcount:~-9%"
echo !text! > "C:\Temp\DocTemp\doctemp.txtline%lcount:~-9%"
echo This File Exists^! > "C:\Temp\DocTemp\unsaved" 2> nul
if not "%dir%"=="%baseline%" echo %dir%> "C:\Temp\DocTemp\dir" 2> nul
echo %filename%> "C:\Temp\DocTemp\filename" 2> nul
attrib -h "C:\Temp\DocTemp\undo"
echo %undo% > "C:\Temp\DocTemp\undo"
attrib +h "C:\Temp\DocTemp\unsaved" 2> nul
attrib +h "C:\Temp\DocTemp\dir" 2> nul
attrib +h "C:\Temp\DocTemp\filename" 2> nul
attrib +h "C:\Temp\DocTemp\undo"
goto :rebuild
:addnewtextline
attrib -h "C:\Temp\DocTemp\doctemp.txtline%lcount:~-9%"
copy "C:\Temp\DocTemp\doctemp.txtline%lcount:~-9%" "C:\Temp\DocTemp\doctemp.txtline%lcount:~-9%temp" > nul
echo !text! > "C:\Temp\DocTemp\doctemp.txtline%lcount:~-9%"
type "C:\Temp\DocTemp\doctemp.txtline%lcount:~-9%temp" >> "C:\Temp\DocTemp\doctemp.txtline%lcount:~-9%"
del "C:\Temp\DocTemp\doctemp.txtline%lcount:~-9%temp"
attrib +h "C:\Temp\DocTemp\doctemp.txtline%lcount:~-9%"
goto :rebuild
:linelinebreak
attrib -h "C:\Temp\DocTemp\doctemp.txtline%lcount:~-9%"
if %newline% equ 1 (
copy "C:\Temp\DocTemp\doctemp.txtline%lcount:~-9%" "C:\Temp\DocTemp\doctemp.txtline%lcount:~-9%temp" > nul
echo. > "C:\Temp\DocTemp\doctemp.txtline%lcount:~-9%"
type "C:\Temp\DocTemp\doctemp.txtline%lcount:~-9%temp" >> "C:\Temp\DocTemp\doctemp.txtline%lcount:~-9%"
del "C:\Temp\DocTemp\doctemp.txtline%lcount:~-9%temp"
goto :rebuild
)
echo. > "C:\Temp\DocTemp\doctemp.txtline%lcount:~-9%"
goto :rebuild
:rebuild
echo We can defeat COVID!
set lcount=2000000000
set /a lcount+=1
type "C:\Temp\DocTemp\doctemp.txtline%lcount:~-9%" > "C:\Temp\DocTemp\doctemp.txt"
:rebuildlinebyline
set /a lcount+=1
type "C:\Temp\DocTemp\doctemp.txtline%lcount:~-9%" >> "C:\Temp\DocTemp\doctemp.txt"
if %lcount:~-9% geq %fcount2% (
call :SPLIT
setlocal ENABLEDELAYEDEXPANSION
del C:\Temp\DocTemp\temp.txt 2> nul
set /p fcount2= < "C:\Temp\DocTemp\doctemp.txtfcount" 2> nul
del "C:\Temp\DocTemp\doctemp.txtfcount" 2> nul
set lcount=2000000000
goto :textadd
)
goto :rebuildlinebyline
:undoclear
set undo=11
:undoclear1
if %undo% equ 1 set undo=11
del /a h "C:\Temp\DocTemp\doctemp.txt%undo%" 2> nul
set /a undo-=1
if %undo% leq 1 (
set exit=1
goto :exit )
goto :undoclear1
:help
cls
echo Welcome to the help for %WinTXT%, A Command Line Editor For Windows!
echo.
echo #1: How to enter commands:
echo At the "Type:" prompt, type the one of the commands shown below:
echo.
echo #2: Commands:
echo.
echo /exit : Exit %WinTXT%.
echo /undo : Undo the previous command.
echo /help : This help screen.
echo /redo : Redo the previous undone command.
echo /delfile : Delete the current file. (can be undone with /undo.)
echo /linebreak : Insert a line break.
echo /commandsoff : Turn off all commands except:
echo /commandson : Turns commands back off (can't be run before running /commandsoff)
echo /editline (line number) : Edit that line
echo /newline (line number) : Add that line
echo and /delline : Delete that line
echo.
echo And, if you encounter any bugs / need any help, please email helpmewithstuff@protonmail.com .
pause
cls
echo Thank you for using %WinTXT%.
pause
goto :textadd
:exit
set undo=1
del /a h "C:\Temp\DocTemp\doctemp.txt%undo%" 2> nul
set undo=1
del /a h "C:\Temp\DocTemp\doctemp.txt%undo%" 2> nul
cls
set lcount=2000000000
set /a fcount2+=1000
set /a fcount2+=2000000000
set fcount=%fcount:~-9%
:deltemp
set /a lcount+=1
if exist "C:\Temp\DocTemp\doctemp.txtline%lcount:~-9%" (
attrib -h "C:\Temp\DocTemp\doctemp.txtline%lcount:~-9%" > nul 2> nul
del "C:\Temp\DocTemp\doctemp.txtline%lcount:~-9%" > nul 2> nul
)
if %lcount:~-9% geq %fcount2:~-9% goto :exit2
goto :deltemp
:exit2
set /a lcount+=1
attrib -h "C:\Temp\DocTemp\doctemp.txtline%lcount:~-9%" > nul 2> nul
del "C:\Temp\DocTemp\doctemp.txtline%lcount:~-9%" > nul 2> nul
set /a lcount+=1
attrib -h "C:\Temp\DocTemp\doctemp.txtline%lcount:~-9%" > nul 2> nul
del "C:\Temp\DocTemp\doctemp.txtline%lcount:~-9%" > nul 2> nul
call :save
cls
echo Thank you for using %WinTXT%!
echo I hope it's not too terrible. hehe
pause
choice /c yn /n /m "Do you want to edit another file? Y/N"
if %errorlevel% equ 1 (
set undo=0
set deleted=0
set newline=0
set typefileonce=0
set splitfileonce=0
set exit=0
set commandsoff=0
set dir=
set filename=
if exist C:\Temp\DocTemp\doctemp.txt (
del C:\Temp\DocTemp\doctemp.txt )
goto :start
)
if %errorlevel% equ 2 (
title cmd
del C:\Temp\DocTemp\doctemp.txt
del /ah /q C:\Temp\DocTemp\unsaved
del /ah /q C:\Temp\DocTemp\dir
del /ah /q C:\Temp\DocTemp\filename
rmdir C:\Temp\DocTemp\
cls
exit /b
exit /b
exit /b
)
exit /b