p4-editor
EECS 280 Project 4: Text Editor
Due 8:00pm Tuesday April 2, 2024. You may work alone or with a partner (partnership guidelines).
Change Log
2023-03-15 We’ve released an updated version of the starter files:
TextBuffer.hpp now contains improved RMEs and other comments. We suggest you download a new copy of this file if you started the project before this change.
The output of the provided line.cpp testing utility now better reflects the underlying TextBuffer functions.
Implementation details of the project have not changed.
Introduction
The learning goals of this project include Container ADTs, Dynamic Memory, The Big Three, Linked Lists, and Iterators. You will gain experience with new and delete , constructors and destructors, and the List data structure that is similar to std::list from the standard library.
When you’re done, you’ll have implemented the basic features of a text editor that is usable through a terminal-based visual editor, similar to other terminal editors such as Pico, nano, Emacs, and vi.
Setup
Set up your visual debugger and version control, then submit to the autograder.
Visual debugger
During setup, name your project p4-editor . Use this starter files link:
https://eecs280staff.github.io/p4-editor/starter-files.tar.gz
VS Code Visual Studio Xcode
You should end up with a folder with starter files that look like this. You may have already renamed files like List.hpp.starter to List.hpp .
$ ls
List.hpp.starter e0.cpp
List_compile_check.cpp femto.cpp
List_compile_check.out.correct line.cpp
List_public_tests.cpp line_test1.in
List_tests.cpp.starter line_test1.out.correct
Makefile line_test2.in
TextBuffer.hpp line_test2.out.correct
TextBuffer_public_tests.cpp unit_test_framework.hpp
TextBuffer_tests.cpp.starter
Here’s a short description of each starter file.
Version control
Set up version control using the Version control tutorial.
After you’re done, you should have a local repository with a “clean” status and your local repository should be connected to a remote GitHub repository.
$ git status
On branch main
Your branch is up-to-date with 'origin/main'.
nothing to commit, working tree clean
$ git remote -v
origin https://github.com/awdeorio/p4-editor.git (fetch)
origin https://githubcom/awdeorio/p4-editor.git (push)3/15/24, 9:47 PM
You should have a .gitignore file (instructions).
$ head .gitignore
# This is a sample .gitignore file that's useful for C++ projects.
...
Group registration
Register your partnership (or working alone) on the Autograder. Then, submit the code you have.
Linked list
Implement your doubly-linked list in List.hpp . List.hpp.starter provides prototypes for each function. Because List is a templated container, function implementations go in List.hpp . There is no List.cpp .
While the List from lecture was singly linked, this List is doubly linked. This List also contains an iterator interface. The iterator keeps track of both the current node as well as the List to which it belongs – this allows us to go backwards from an end iterator by looking up the last node in the List .
Do not modify the public interface of the List class. Implement a doubly-linked list. No arrays or vectors, etc. Manage memory allocation so that there are no memory leaks (Leak checking tutorial).
Compile and run the provided compile check and List tests.
$ make List_compile_check.exe
$ make List_public_tests.exe
$ ./List_public_tests.exe
Write tests for List in List_tests.cpp using the Unit Test Framework. You’ll submit these tests to the autograder. See the Unit Test Grading section.
$ make List_tests.exe
$ ./List_tests.exe
Pro-tip: Getting an error about typename ? Take a look at our reference on Typename.
Setup
Rename these files (VS Code (macOS), VS Code (Windows), Visual Studio, Xcode, CLI):
List.hpp.starter -> List.hpp
List_tests.cpp.starter -> List_tests.cpp
Edit List.hpp , adding a function stub for each member function declared in List.hpp , either inside or outside the class definition: For example:
1 // Inside the class definition:
2 template
3 class List {
4 ...
5
6 bool empty() const {
7 assert(false);
8 }
9
10 ...
11 };
12
13 // Or, outside the class definition:
14 template
15 bool List
16 assert(false);
17 }
The List tests should compile and run. The public tests will fail until you implement the functions.
The file for your test cases ( List_tests.cpp ) will pass because it initially only contains ASSERT_TRUE(true) .
$ make List_public_tests.exe
$ ./List_public_tests.exe
$ make List_tests.exe
$ ./List_tests.exe
At this point, we haven’t written the List Iterator, so List_compile_check.exe won’t compile. You’ll need to take a look at the lecture about iterators and write your own tests. After you do, use the provided compile check like this:
$ make List_compile_check.exe
Configure your IDE to debug either the public tests or your own tests.
TextBuffer
A text buffer holds an editable sequence of characters and at the same time has the ability to report the current row and column (You can display this information in Pico/nano with Ctrl-C , or in Emacs by typing M-x line-number-mode and M-x column-number-mode .). The text buffer keeps track of the current cursor position where all edits are done and allows scrolling using the arrow keys to move the cursor through the text.
In this section, you will implement the TextBuffer class according the interface defined in the TextBuffer.hpp file. The data representation of a TextBuffer is a doubly linked list of characters (either your implementation from part 1 or std::list from the C++ standard library). The TextBuffer also stores an iterator that indicates the current position of the cursor, the current row and column position, and the index of the cursor with respect to the entire buffer (i.e. how many characters from the start to the cursor).
The definition of the TextBuffer class is shown below:3/15/24, 9:47 PM
1 class TextBuffer {
2 using CharList = std::list
3 using Iterator = std::list
4 private:
5 CharList data; // linked list that contains the characters
6 Iterator cursor; // current position within the list
7 int row; // current row
8 int column; // current column
9 int index; // current index
10 // ... public interface not shown
11 };
版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。