Coder Social home page Coder Social logo

matthewdeanmartin / dedlin Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 0.0 458 KB

Clone of edlin with improvements to make it into more of a DSL

License: MIT License

Python 95.95% Shell 1.01% Makefile 2.55% Dockerfile 0.46% PowerShell 0.03%
editor edlin line-editor

dedlin's Introduction

👋

My name is Matthew Martin.

I am Software Developer currently in greater Washington, DC. I'm a tech lead at a big organization in DC.

Languages

  • Python (current main language) 🐍
  • C# #️⃣
  • Javascript/Typescript 🌐

Projects/Applications

Libraries

📬 My social media

dedlin's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

dedlin's Issues

Page command

Page command needs to show pages one batch at a time in order to be reader friendly. Showing all pages at once is not easy to read.

--- Current line is 12, 12 lines total ---
 * l
   1 : a
   2 : b
   3 : c
   4 : d
   5 : e
   6 : f
   7 : g
   8 : h
   9 : i
   10 : j
   11 : k
   12 : l
--- Current line is 1, 12 lines total ---
 * p
   1 : a
   2 : b
   3 : c
   4 : d
   5 : e
 * p
 *   6 : f
   7 : g
   8 : h
   9 : i
   10 : j
 * p
   11 : k
   12 : l

Crashes when "current" set to non-existent line

Crashes when "current" set to non-existent line. In this case, line goes up to 9. There is no line 20.

--- Current line is 2, 9 lines total ---
 * p
   2 : flour
   3 : C
   4 : peaches
   5 : almonds
   6 : soymilk
--- Current line is 7, 9 lines total ---
 * p
   7 : bear
   8 : cat
   9 : dog
--- Current line is 9, 9 lines total ---
 * 0 current
--- Current line is 1, 9 lines total ---
 * 20 current
--- Current line is 20, 9 lines total ---
 * p
Error in sys.excepthook:
Traceback (most recent call last):
  File "C:\Users\matth\.virtualenvs\try_dedlin-aGxF52TV\Lib\site-packages\dedlin\main.py", line 317, in save_on_crash
    raise type
icontract.errors.ViolationError

Original exception was:
Traceback (most recent call last

List command shows extra line

Command to list lines 1-3 but it listed lines 1-4...

 * 1, 3 list
   1 : cat
   2 : dogs
   3 : rabbit
   4 : red
--- Current line is 5, 5 lines total ---
 *

Crashes when (set current line to 0)

Bug. Crashes when (set current line to 0).

--- Current line is 6, 6 lines total ---
 * 0 current
Error in sys.excepthook:
Traceback (most recent call last):
  File "/home/pia/test_dedlin/venv/lib/python3.10/site-packages/dedlin/main.py", line 307, in save_on_crash
    raise type
  File "pydantic/error_wrappers.py", line 53, in pydantic.error_wrappers.ValidationError.__init__
TypeError: __init__() takes exactly 3 positional arguments (1 given)

Original exception was:
Traceback (most recent call last):
  File "/home/pia/test_dedlin/venv/bin/dedlin", line 8, in <module>
    sys.exit(main())
  File "/home/pia/test_dedlin/venv/lib/python3.10/site-packages/dedlin/__main__.py", line 42, in main
    _ = run(
  File "/home/pia/test_dedlin/venv/lib/python3.10/site-packages/dedlin/__main__.py", line 125, in run
    dedlin.save_on_crash(the_exception, None, None)
  File "/home/pia/test_dedlin/venv/lib/python3.10/site-packages/dedlin/main.py", line 307, in save_on_crash
    raise type
  File "/home/pia/test_dedlin/venv/lib/python3.10/site-packages/dedlin/__main__.py", line 118, in run
    dedlin.entry_point(file_name, macro_file_name)
  File "/home/pia/test_dedlin/venv/lib/python3.10/site-packages/dedlin/main.py", line 110, in entry_point
    command = next(command_generator)
  File "/home/pia/test_dedlin/venv/lib/python3.10/site-packages/dedlin/command_sources.py", line 49, in generate
    command = parse_command(
  File "/home/pia/test_dedlin/venv/lib/python3.10/site-packages/dedlin/parsers.py", line 285, in parse_command
    candidate = parse_range_only(just_command, front_part, original_text, current_line, document_length, phrases)
  File "/home/pia/test_dedlin/venv/lib/python3.10/site-packages/dedlin/parsers.py", line 147, in parse_range_only
    line_range = extract_one_range(range_text, current_line, document_length)
  File "/home/pia/test_dedlin/venv/lib/python3.10/site-packages/dedlin/parsers.py", line 59, in extract_one_range
    candidate = LineRange(start=start, offset=0, repeat=1)
  File "<string>", line 6, in __init__
  File "pydantic/dataclasses.py", line 100, in pydantic.dataclasses._generate_pydantic_post_init._pydantic_post_init
    # +-------+-------+-------+
pydantic.error_wrappers.ValidationError: 1 validation error for LineRange
start
  start must be one or more (type=value_error)
(venv) pia@pia-envy:~/test_dedlin$ ^C
(venv) pia@pia-envy:~/test_dedlin$ 


Command for COPY is needed

Command for COPY is needed.

Actual...
Copy line 1 to 3

 * help reorder
Reorder Commands
[range] Move [target line number] - move range to target
[range] Copy [target line number] - copy range to target
[range] Sort - sort lines alphabetically
[range] Shuffle - shuffle lines randomly
--- Current line is 1, 3 lines total ---
 * l
   1 : house
   2 : mouse
   3 : blouse
--- Current line is 1, 3 lines total ---
 * 1 copy 3
Unknown command, type HELP for help

What I expected...
Copy line 1 to 3

 * help reorder
Reorder Commands
[range] Move [target line number] - move range to target
[range] Copy [target line number] - copy range to target
[range] Sort - sort lines alphabetically
[range] Shuffle - shuffle lines randomly
--- Current line is 1, 3 lines total ---
 * l
   1 : house
   2 : mouse
   3 : blouse
--- Current line is 1, 3 lines total ---
 * 1 copy 3
--- Current line is 1, 3 lines total ---
   1 : house
   2 : mouse
   3 : house

Page command bug

First bug: set current line to 1, then page command. List started at #2 cat when it should be #1 cat.
Second bug: set current line to 0 and it crashed.

--- Current line is 5, 5 lines total ---
 * 1, 3 list
   1 : cat
   2 : dogs
   3 : rabbit
   4 : red
--- Current line is 5, 5 lines total ---
 * help display
Display Commands
[range] List - display lines, set current to end of range
[range] Page - repeat to flip through entire document
[range] Spell - show spelling mistakes
[range] Search "[text]" 
--- Current line is 5, 5 lines total ---
 * 1 current
--- Current line is 1, 5 lines total ---
 * page
   2 : cat
   3 : dogs
   4 : rabbit
   5 : red
   6 : purple
--- Current line is 5, 5 lines total ---
 * 0 current
Traceback (most recent call last):
  File "/home/pia/test_dedlin/venv/lib/python3.10/site-packages/dedlin/__main__.py", line 117, in run
    dedlin.entry_point(file_name, macro_file_name)
  File "/home/pia/test_dedlin/venv/lib/python3.10/site-packages/dedlin/main.py", line 109, in entry_point
    command = next(command_generator)
  File "/home/pia/test_dedlin/venv/lib/python3.10/site-packages/dedlin/command_sources.py", line 48, in generate
    command = parse_command(
  File "/home/pia/test_dedlin/venv/lib/python3.10/site-packages/dedlin/parsers.py", line 284, in parse_command
    candidate = parse_range_only(just_command, front_part, original_text, current_line, document_length, phrases)
  File "/home/pia/test_dedlin/venv/lib/python3.10/site-packages/dedlin/parsers.py", line 147, in parse_range_only
    line_range = extract_one_range(range_text, current_line, document_length)
  File "/home/pia/test_dedlin/venv/lib/python3.10/site-packages/dedlin/parsers.py", line 59, in extract_one_range
    candidate = LineRange(start=start, offset=0, repeat=1)
  File "<string>", line 6, in __init__
  File "pydantic/dataclasses.py", line 100, in pydantic.dataclasses._generate_pydantic_post_init._pydantic_post_init
pydantic.error_wrappers.ValidationError: 1 validation error for LineRange
start
  start must be one or more (type=value_error)

History saved to /home/pia/test_dedlin/venv/lib/python3.10/site-packages/dedlin/.dedlin_history/history31.ed
(venv) pia@pia-envy:~/test_dedlin$ 

Edit prompt is missing

Actual

--- Current line is 4, 4 lines total ---
 * l
   1 : Apple
   2 : Bat
   3 : C
   4 : D
--- Current line is 4, 4 lines total ---
 * 4
[Control C]-[Enter] to exit edit mode
Dog
Went beyond end of document, signalling nothing more to edit

--- Current line is 4, 4 lines total ---

This is what I expected:

--- Current line is 4, 4 lines total ---
 * l
   1 : Apple
   2 : Bat
   3 : C
   4 : D
--- Current line is 4, 4 lines total ---
 * 4
[Control C]-[Enter] to exit edit mode
4: Dog
Went beyond end of document, signalling nothing more to edit

User should have options to insert more lines after editing last line

Control C to exit insert mode
?   1 :  A
?   2 :  B
?   3 :  C
?   4 :
?   5 :                                                                                                                                                                                                     

Exiting insert mode

--- Current line is 4, 4 lines total ---
 * 4 edit
[Control C]-[Enter] to exit edit mode
D
Went beyond end of document, signalling nothing more to edit

--- Current line is 4, 4 lines total ---
 * 1
[Control C]-[Enter] to exit edit mode
Apple
Bat
C
D
Went beyond end of document, signalling nothing more to edit

Spell check failed to catch several spelling errors

--- Current line is 0, 0 lines total ---
 * 1i
Control C to exit insert mode
?   1 :  sllow
?   2 :  faast
?   3 :  dogg
?   4 :  catt
?   5 :  book
?   6 :  worm
?   7 :  money
?   8 :  3g46
?   9 :                                                                                                                                                                                                     

Exiting insert mode

--- Current line is 8, 8 lines total ---
 * spell
   1 : sllow (did you mean allow?)

   2 : faast (did you mean fast?)

   3 : dogg

   4 : catt (did you mean cat?)

   5 : book

   6 : worm

   7 : money

   8 : 3g46

--- Current line is 9, 8 lines total ---
 *

Bug. Spell check failed to catch several spelling errors. In this case the words (1.slow 3.dog 8.3g46).

Edit prompt is missing number to identify which line number is being edited

Edit prompt is missing number to identify which line number is being edited.

Actual

--- Current line is 5, 5 lines total ---
 * l
   1 : top
   2 : mop
   3 : flop
   4 : drop
   5 : crop
--- Current line is 5, 5 lines total ---
 * 4
[Control C]-[Enter] to exit edit mode
* drop

What I expected

--- Current line is 5, 5 lines total ---
 * l
   1 : top
   2 : mop
   3 : flop
   4 : drop
   5 : crop
--- Current line is 5, 5 lines total ---
 * 4
[Control C]-[Enter] to exit edit mode
* 4: drop

Fails to capture line breaks for browse command - after browsing and saving file.

 * history
1,1000 browse http://wikipedia.org
1 current
l
help all
history
--- Current line is 358, 358 lines total ---
 * e
(venv) pia@pia-envy:~/test_d ТаÑ�аÑ�Ñ�а / Tatarça ภาษา๠                                                                inaСÑ�пÑ�ки / Srpski Srpskohrvatski / СÑ�пÑ�ÐºÐ¾Ñ Ñ�ваÑ�Ñ�ки SuomiSvenska தமிழà¯ano ×¢×�ר×�ת á�¥á�акедонÑ�ки Ù à¸à¸¢Ð¢Ð¾Ò·Ð¸ÐºÓ£ تÛرکجÙ� Türkçe УкÑ�аÑнÑ�Ñ�ка ارد٠TiếngViá»�t Volapük Winaray ç²µèª� 中æ�___Search___ Read Wikipedia in your language  __##  1 000 000+  articles* Polski* اÙÄ�Ð Ñ�Ñ�Ñ�кий Simple English Sinugboanong Binisaya SlovenÄ
                                     

Fails to capture line breaks for browse command - after browsing and saving file.

Bug: Crashes on editing

--- Current line is 4, 4 lines total ---
*l
1,4 LIST 
   1 : Dear Santa,

   2 : Please give me toys.

   3 : Thanks,

   4 : Pia

--- Current line is 5, 4 lines total ---
*4
4 EDIT 
[Control C], [Enter] to exit edit mode
   4 : Pia Noelle
Traceback (most recent call last):
  File "/home/pia/test_dedlin/venv/bin/dedlin", line 8, in <module>
    sys.exit(main())
  File "/home/pia/test_dedlin/venv/lib/python3.10/site-packages/dedlin/__main__.py", line 29, in main
    _ = run(
  File "/home/pia/test_dedlin/venv/lib/python3.10/site-packages/dedlin/main.py", line 261, in run
    dedlin.entry_point(file_name, macro_file_name)
  File "/home/pia/test_dedlin/venv/lib/python3.10/site-packages/dedlin/main.py", line 164, in entry_point
    line_number = self.doc.edit(line_number)
  File "/home/pia/test_dedlin/venv/lib/python3.10/site-packages/dedlin/document.py", line 189, in edit
    line_text = self.lines[line_number - 1]
IndexError: list index out of range
(venv) pia@pia-envy:~/test_dedlin$ 

Created document. Tried to edit and hit Enter key to exit edit mode and it crashed.

Move command needed

Move command needed. HELP display lists Move command as option....

For more help, type
HELP display|edit|files|data|reorder|meta|data|all
--- Current line is 1, 3 lines total ---
 * help reorder
Reorder Commands
[range] Move [target line number] - move range to target

Actual...
Move line 1 to line 3...

--- Current line is 1, 3 lines total ---
 * l
   1 : house
   2 : blouse
   3 : mouse
--- Current line is 1, 3 lines total ---
 * 1 move 3
Unknown command, type HELP for help
--- Current line is 1, 3 lines total ---
 * l
   1 : house
   2 : blouse
   3 : mouse

What I expected...
Move line 1 to line 3...

--- Current line is 1, 3 lines total ---
 * l
   1 : house
   2 : blouse
   3 : mouse
--- Current line is 1, 3 lines total ---
 * 1 move 3
Unknown command, type HELP for help
--- Current line is 1, 3 lines total ---
 * l
   1 : mouse
   2 : blouse
   3 : house

Crashes if you run List (l), then insert first line (1i), but if you don't run List first it doesn't crash.

Editing /home/pia/test_dedlin/testpart2.txt
 * l
--- Current line is 1, 0 lines total ---
 * 1i
Control C to exit insert mode
Traceback (most recent call last):
  File "/home/pia/test_dedlin/venv/bin/dedlin", line 8, in <module>
    sys.exit(main())
  File "/home/pia/test_dedlin/venv/lib/python3.10/site-packages/dedlin/__main__.py", line 35, in main
    _ = run(
  File "/home/pia/test_dedlin/venv/lib/python3.10/site-packages/dedlin/__main__.py", line 85, in run
    dedlin.entry_point(file_name, macro_file_name)
  File "/home/pia/test_dedlin/venv/lib/python3.10/site-packages/dedlin/main.py", line 155, in entry_point
    self.doc.insert(line_number)
  File "/home/pia/test_dedlin/venv/lib/python3.10/site-packages/dpcontracts.py", line 507, in inner
    raise PreconditionError(description)
dpcontracts.PreconditionError: Current line must be a valid line
(venv) pia@pia-envy:~/test_dedlin$ ^C
(venv) pia@pia-envy:~/test_dedlin$ ^C
(venv) pia@pia-envy:~/test_dedlin$ 

Crashes if you run List (l), then insert first line (1i), but if you don't run List first it doesn't crash.

Bug in Move command - Moved a line but line was not removed.

Bug in Move command. Moved line 2 to 6. Line 2 (fox) was moved to line 6 (fox) but line 2 (fox) was not removed.



 * l
   1 : bear
   2 : fox
   3 : cat
   4 : rabbit
   5 : bird
   6 : dog
   7 : snake
   8 : mouse
   9 : bug
   10 : lion
   11 : moose
   12 : owl
   13 : 1
   14 : 1
--- Current line is 14, 14 lines total ---
 * 2 move 6
Moved
--- Current line is 6, 15 lines total ---
 * l
   1 : bear
   2 : fox
   3 : cat
   4 : rabbit
   5 : bird
   6 : fox
   7 : dog
   8 : snake
   9 : mouse
   10 : bug
   11 : lion
   12 : moose
   13 : owl
   14 : 1
   15 : 1
--- Current line is 6, 15 lines total ---

Bug found when deleting lines

--- Current line is 0, 0 lines total ---
 * 1i
Control C to exit insert mode
?   1 :  cheese
?   2 :  bread
?   3 :  apples
?   4 :  cookies
?   5 :  milk
?   6 :                                                                                                                                                                                                     

Exiting insert mode

--- Current line is 5, 5 lines total ---
 * l
   1 : cheese

   2 : bread

   3 : apples

   4 : cookies

   5 : milk

--- Current line is 5, 5 lines total ---
 * 1, 3 delete
Traceback (most recent call last):
  File "/home/pia/test_dedlin/venv/bin/dedlin", line 8, in <module>
    sys.exit(main())
  File "/home/pia/test_dedlin/venv/lib/python3.10/site-packages/dedlin/__main__.py", line 35, in main
    _ = run(
  File "/home/pia/test_dedlin/venv/lib/python3.10/site-packages/dedlin/__main__.py", line 87, in run
    dedlin.entry_point(file_name, macro_file_name)
  File "/home/pia/test_dedlin/venv/lib/python3.10/site-packages/dedlin/main.py", line 146, in entry_point
    self.doc.delete(command.line_range)
  File "/home/pia/test_dedlin/venv/lib/python3.10/site-packages/dpcontracts.py", line 513, in inner
    raise PostconditionError(description)
dpcontracts.PostconditionError: Current line must be a valid line
(venv) pia@pia-envy:~/test_dedlin$ 

Bug found when deleting lines. In this case, a list was created, then command to delete lines 1 and 3, resulting in crash.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.