written an initial readme, removed some unnecessary files
This commit is contained in:
@@ -1,93 +1,28 @@
|
||||
# Computersystems Coursework Text Editor
|
||||
|
||||
|
||||
## Usage:
|
||||
|
||||
## Getting started
|
||||
### Compiling:
|
||||
|
||||
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
||||
for this program to compile you need the following C libraries on your system:
|
||||
- ncurses
|
||||
- Linux: usually preinstalled - otherwise installation depends on distro
|
||||
- Mac
|
||||
> brew install ncurses
|
||||
- Windows:
|
||||
- This may be more difficult to setup and requires additional research
|
||||
|
||||
compiling with GCC:
|
||||
> gcc main.c editor.c dynstr.c -lncurses -o <binary-name>
|
||||
|
||||
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
||||
|
||||
## Add your files
|
||||
|
||||
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
||||
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
|
||||
|
||||
```
|
||||
cd existing_repo
|
||||
git remote add origin https://git.cs.bham.ac.uk/hxi486/computersystems-coursework-text-editor.git
|
||||
git branch -M main
|
||||
git push -uf origin main
|
||||
```
|
||||
|
||||
## Integrate with your tools
|
||||
|
||||
- [ ] [Set up project integrations](https://git.cs.bham.ac.uk/hxi486/computersystems-coursework-text-editor/-/settings/integrations)
|
||||
|
||||
## Collaborate with your team
|
||||
|
||||
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
|
||||
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
||||
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
||||
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
||||
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
|
||||
|
||||
## Test and Deploy
|
||||
|
||||
Use the built-in continuous integration in GitLab.
|
||||
|
||||
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
|
||||
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
||||
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
||||
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
||||
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
||||
|
||||
***
|
||||
|
||||
# Editing this README
|
||||
|
||||
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
||||
|
||||
## Suggestions for a good README
|
||||
|
||||
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
||||
|
||||
## Name
|
||||
Choose a self-explaining name for your project.
|
||||
|
||||
## Description
|
||||
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
||||
|
||||
## Badges
|
||||
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
||||
|
||||
## Visuals
|
||||
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
||||
|
||||
## Installation
|
||||
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
||||
|
||||
## Usage
|
||||
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
||||
|
||||
## Support
|
||||
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
||||
|
||||
## Roadmap
|
||||
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
||||
|
||||
## Contributing
|
||||
State if you are open to contributions and what your requirements are for accepting them.
|
||||
|
||||
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
||||
|
||||
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
||||
|
||||
## Authors and acknowledgment
|
||||
Show your appreciation to those who have contributed to the project.
|
||||
|
||||
## License
|
||||
For open source projects, say how it is licensed.
|
||||
|
||||
## Project status
|
||||
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
||||
### Running:
|
||||
```bash
|
||||
./<binary-name> open <$file> # opens the specified file in the editor
|
||||
./<binary-name> new <$file> # creates a new file with <filename> as the name
|
||||
./<binary-name> del <$file> # deletes the specified file
|
||||
./<binary-name> copy <$file> <$newpath> # copies $file to the location $newpath
|
||||
./<binary-name> move <$file> <$newpath> # moves $file to the location $newpath
|
||||
./<binary-name> len <$file> # prints the length of $file
|
||||
./<binary-name> log <$file> # prints the change history of $file
|
||||
```
|
||||
Binary file not shown.
-258
@@ -1,258 +0,0 @@
|
||||
starting editor openiing file somecode.cln: 1, col: 0 xoff: 0 yoff: 0
|
||||
ln: 2, col: 0 xoff: 0 yoff: 0
|
||||
ln: 3, col: 0 xoff: 0 yoff: 0
|
||||
ln: 4, col: 0 xoff: 0 yoff: 0
|
||||
ln: 5, col: 0 xoff: 0 yoff: 0
|
||||
ln: 6, col: 0 xoff: 0 yoff: 0
|
||||
ln: 7, col: 0 xoff: 0 yoff: 0
|
||||
ln: 8, col: 0 xoff: 0 yoff: 0
|
||||
ln: 9, col: 0 xoff: 0 yoff: 0
|
||||
ln: 10, col: 0 xoff: 0 yoff: 0
|
||||
ln: 11, col: 0 xoff: 0 yoff: 0
|
||||
ln: 12, col: 0 xoff: 0 yoff: 0
|
||||
ln: 13, col: 0 xoff: 0 yoff: 0
|
||||
ln: 14, col: 0 xoff: 0 yoff: 0
|
||||
ln: 15, col: 0 xoff: 0 yoff: 0
|
||||
ln: 16, col: 0 xoff: 0 yoff: 0
|
||||
ln: 17, col: 0 xoff: 0 yoff: 0
|
||||
ln: 18, col: 0 xoff: 0 yoff: 0
|
||||
ln: 19, col: 0 xoff: 0 yoff: 0
|
||||
ln: 20, col: 0 xoff: 0 yoff: 0
|
||||
ln: 21, col: 0 xoff: 0 yoff: 0
|
||||
ln: 22, col: 0 xoff: 0 yoff: 0
|
||||
ln: 23, col: 0 xoff: 0 yoff: 0
|
||||
ln: 24, col: 0 xoff: 0 yoff: 0
|
||||
ln: 25, col: 0 xoff: 0 yoff: 0
|
||||
ln: 26, col: 0 xoff: 0 yoff: 0
|
||||
ln: 27, col: 0 xoff: 0 yoff: 0
|
||||
ln: 28, col: 0 xoff: 0 yoff: 0
|
||||
ln: 29, col: 0 xoff: 0 yoff: 0
|
||||
ln: 30, col: 0 xoff: 0 yoff: 0
|
||||
ln: 31, col: 0 xoff: 0 yoff: 0
|
||||
ln: 32, col: 0 xoff: 0 yoff: 0
|
||||
ln: 33, col: 0 xoff: 0 yoff: 0
|
||||
ln: 34, col: 0 xoff: 0 yoff: 0
|
||||
ln: 35, col: 0 xoff: 0 yoff: 0
|
||||
ln: 36, col: 0 xoff: 0 yoff: 0
|
||||
ln: 37, col: 0 xoff: 0 yoff: 1
|
||||
ln: 38, col: 0 xoff: 0 yoff: 2
|
||||
ln: 39, col: 0 xoff: 0 yoff: 3
|
||||
ln: 40, col: 0 xoff: 0 yoff: 4
|
||||
ln: 41, col: 0 xoff: 0 yoff: 5
|
||||
ln: 42, col: 0 xoff: 0 yoff: 6
|
||||
ln: 43, col: 0 xoff: 0 yoff: 7
|
||||
ln: 44, col: 0 xoff: 0 yoff: 8
|
||||
ln: 45, col: 0 xoff: 0 yoff: 9
|
||||
ln: 46, col: 0 xoff: 0 yoff: 10
|
||||
ln: 47, col: 0 xoff: 0 yoff: 11
|
||||
ln: 48, col: 0 xoff: 0 yoff: 12
|
||||
ln: 49, col: 0 xoff: 0 yoff: 13
|
||||
ln: 50, col: 0 xoff: 0 yoff: 14
|
||||
ln: 51, col: 0 xoff: 0 yoff: 15
|
||||
ln: 52, col: 0 xoff: 0 yoff: 16
|
||||
ln: 53, col: 0 xoff: 0 yoff: 17
|
||||
ln: 54, col: 0 xoff: 0 yoff: 18
|
||||
ln: 55, col: 0 xoff: 0 yoff: 19
|
||||
ln: 56, col: 0 xoff: 0 yoff: 20
|
||||
ln: 57, col: 0 xoff: 0 yoff: 21
|
||||
ln: 58, col: 0 xoff: 0 yoff: 22
|
||||
ln: 59, col: 0 xoff: 0 yoff: 23
|
||||
ln: 60, col: 0 xoff: 0 yoff: 24
|
||||
ln: 61, col: 0 xoff: 0 yoff: 25
|
||||
ln: 62, col: 0 xoff: 0 yoff: 26
|
||||
ln: 63, col: 0 xoff: 0 yoff: 27
|
||||
ln: 64, col: 0 xoff: 0 yoff: 28
|
||||
ln: 65, col: 0 xoff: 0 yoff: 29
|
||||
ln: 66, col: 0 xoff: 0 yoff: 30
|
||||
ln: 67, col: 0 xoff: 0 yoff: 31
|
||||
ln: 68, col: 0 xoff: 0 yoff: 32
|
||||
ln: 69, col: 0 xoff: 0 yoff: 33
|
||||
ln: 70, col: 0 xoff: 0 yoff: 34
|
||||
ln: 71, col: 0 xoff: 0 yoff: 35
|
||||
ln: 72, col: 0 xoff: 0 yoff: 36
|
||||
ln: 73, col: 0 xoff: 0 yoff: 37
|
||||
ln: 74, col: 0 xoff: 0 yoff: 38
|
||||
ln: 75, col: 0 xoff: 0 yoff: 39
|
||||
ln: 76, col: 0 xoff: 0 yoff: 40
|
||||
ln: 77, col: 0 xoff: 0 yoff: 41
|
||||
ln: 78, col: 0 xoff: 0 yoff: 42
|
||||
ln: 79, col: 0 xoff: 0 yoff: 43
|
||||
ln: 80, col: 0 xoff: 0 yoff: 44
|
||||
ln: 81, col: 0 xoff: 0 yoff: 45
|
||||
ln: 82, col: 0 xoff: 0 yoff: 46
|
||||
ln: 83, col: 0 xoff: 0 yoff: 47
|
||||
ln: 84, col: 0 xoff: 0 yoff: 48
|
||||
ln: 85, col: 0 xoff: 0 yoff: 49
|
||||
ln: 86, col: 0 xoff: 0 yoff: 50
|
||||
ln: 87, col: 0 xoff: 0 yoff: 51
|
||||
ln: 88, col: 0 xoff: 0 yoff: 52
|
||||
ln: 89, col: 0 xoff: 0 yoff: 53
|
||||
ln: 90, col: 0 xoff: 0 yoff: 54
|
||||
ln: 91, col: 0 xoff: 0 yoff: 55
|
||||
ln: 92, col: 0 xoff: 0 yoff: 56
|
||||
ln: 93, col: 0 xoff: 0 yoff: 57
|
||||
ln: 94, col: 0 xoff: 0 yoff: 58
|
||||
ln: 95, col: 0 xoff: 0 yoff: 59
|
||||
ln: 96, col: 0 xoff: 0 yoff: 60
|
||||
ln: 97, col: 0 xoff: 0 yoff: 61
|
||||
ln: 98, col: 0 xoff: 0 yoff: 62
|
||||
ln: 99, col: 0 xoff: 0 yoff: 63
|
||||
ln: 100, col: 0 xoff: 0 yoff: 64
|
||||
ln: 101, col: 0 xoff: 0 yoff: 65
|
||||
ln: 102, col: 0 xoff: 0 yoff: 66
|
||||
ln: 103, col: 0 xoff: 0 yoff: 67
|
||||
ln: 104, col: 0 xoff: 0 yoff: 68
|
||||
ln: 105, col: 0 xoff: 0 yoff: 69
|
||||
ln: 106, col: 0 xoff: 0 yoff: 70
|
||||
ln: 107, col: 0 xoff: 0 yoff: 71
|
||||
ln: 108, col: 0 xoff: 0 yoff: 72
|
||||
ln: 109, col: 0 xoff: 0 yoff: 73
|
||||
ln: 110, col: 0 xoff: 0 yoff: 74
|
||||
ln: 111, col: 0 xoff: 0 yoff: 75
|
||||
ln: 112, col: 0 xoff: 0 yoff: 76
|
||||
ln: 113, col: 0 xoff: 0 yoff: 77
|
||||
ln: 114, col: 0 xoff: 0 yoff: 78
|
||||
ln: 115, col: 0 xoff: 0 yoff: 79
|
||||
ln: 116, col: 0 xoff: 0 yoff: 80
|
||||
ln: 117, col: 0 xoff: 0 yoff: 81
|
||||
ln: 118, col: 0 xoff: 0 yoff: 82
|
||||
ln: 119, col: 0 xoff: 0 yoff: 83
|
||||
ln: 120, col: 0 xoff: 0 yoff: 84
|
||||
ln: 121, col: 0 xoff: 0 yoff: 85
|
||||
ln: 122, col: 0 xoff: 0 yoff: 86
|
||||
ln: 123, col: 0 xoff: 0 yoff: 87
|
||||
ln: 124, col: 0 xoff: 0 yoff: 88
|
||||
ln: 125, col: 0 xoff: 0 yoff: 89
|
||||
ln: 126, col: 0 xoff: 0 yoff: 90
|
||||
ln: 127, col: 0 xoff: 0 yoff: 91
|
||||
ln: 128, col: 0 xoff: 0 yoff: 92
|
||||
ln: 129, col: 0 xoff: 0 yoff: 93
|
||||
ln: 130, col: 0 xoff: 0 yoff: 94
|
||||
ln: 131, col: 0 xoff: 0 yoff: 95
|
||||
ln: 132, col: 0 xoff: 0 yoff: 96
|
||||
ln: 133, col: 0 xoff: 0 yoff: 97
|
||||
ln: 134, col: 0 xoff: 0 yoff: 98
|
||||
ln: 135, col: 0 xoff: 0 yoff: 99
|
||||
ln: 136, col: 0 xoff: 0 yoff: 100
|
||||
ln: 137, col: 0 xoff: 0 yoff: 101
|
||||
ln: 138, col: 0 xoff: 0 yoff: 102
|
||||
ln: 139, col: 0 xoff: 0 yoff: 103
|
||||
ln: 140, col: 0 xoff: 0 yoff: 104
|
||||
ln: 141, col: 0 xoff: 0 yoff: 105
|
||||
ln: 142, col: 0 xoff: 0 yoff: 106
|
||||
ln: 143, col: 0 xoff: 0 yoff: 107
|
||||
ln: 144, col: 0 xoff: 0 yoff: 108
|
||||
ln: 145, col: 0 xoff: 0 yoff: 109
|
||||
ln: 146, col: 0 xoff: 0 yoff: 110
|
||||
ln: 147, col: 0 xoff: 0 yoff: 111
|
||||
ln: 148, col: 0 xoff: 0 yoff: 112
|
||||
ln: 149, col: 0 xoff: 0 yoff: 113
|
||||
ln: 150, col: 0 xoff: 0 yoff: 114
|
||||
ln: 151, col: 0 xoff: 0 yoff: 115
|
||||
ln: 152, col: 0 xoff: 0 yoff: 116
|
||||
ln: 153, col: 0 xoff: 0 yoff: 117
|
||||
ln: 154, col: 0 xoff: 0 yoff: 118
|
||||
ln: 155, col: 0 xoff: 0 yoff: 119
|
||||
ln: 156, col: 0 xoff: 0 yoff: 120
|
||||
ln: 157, col: 0 xoff: 0 yoff: 121
|
||||
ln: 158, col: 0 xoff: 0 yoff: 122
|
||||
ln: 159, col: 0 xoff: 0 yoff: 123
|
||||
ln: 160, col: 0 xoff: 0 yoff: 124
|
||||
ln: 161, col: 0 xoff: 0 yoff: 125
|
||||
ln: 162, col: 0 xoff: 0 yoff: 126
|
||||
ln: 163, col: 0 xoff: 0 yoff: 127
|
||||
ln: 164, col: 0 xoff: 0 yoff: 128
|
||||
ln: 165, col: 0 xoff: 0 yoff: 129
|
||||
ln: 166, col: 0 xoff: 0 yoff: 130
|
||||
ln: 167, col: 0 xoff: 0 yoff: 131
|
||||
ln: 168, col: 0 xoff: 0 yoff: 132
|
||||
ln: 169, col: 0 xoff: 0 yoff: 133
|
||||
ln: 170, col: 0 xoff: 0 yoff: 134
|
||||
ln: 171, col: 0 xoff: 0 yoff: 135
|
||||
ln: 172, col: 0 xoff: 0 yoff: 136
|
||||
ln: 173, col: 0 xoff: 0 yoff: 137
|
||||
ln: 174, col: 0 xoff: 0 yoff: 138
|
||||
ln: 175, col: 0 xoff: 0 yoff: 139
|
||||
ln: 176, col: 0 xoff: 0 yoff: 140
|
||||
ln: 177, col: 0 xoff: 0 yoff: 141
|
||||
ln: 178, col: 0 xoff: 0 yoff: 142
|
||||
ln: 178, col: 0 xoff: 0 yoff: 143
|
||||
ln: 178, col: 0 xoff: 0 yoff: 143
|
||||
ln: 178, col: 0 xoff: 0 yoff: 143
|
||||
ln: 178, col: 0 xoff: 0 yoff: 143
|
||||
ln: 178, col: 0 xoff: 0 yoff: 143
|
||||
ln: 178, col: 0 xoff: 0 yoff: 143
|
||||
ln: 178, col: 0 xoff: 0 yoff: 143
|
||||
ln: 178, col: 0 xoff: 0 yoff: 143
|
||||
ln: 178, col: 0 xoff: 0 yoff: 143
|
||||
ln: 178, col: 0 xoff: 0 yoff: 143
|
||||
ln: 178, col: 0 xoff: 0 yoff: 143
|
||||
ln: 178, col: 0 xoff: 0 yoff: 143
|
||||
ln: 178, col: 0 xoff: 0 yoff: 143
|
||||
ln: 178, col: 0 xoff: 0 yoff: 143
|
||||
ln: 178, col: 0 xoff: 0 yoff: 143
|
||||
ln: 178, col: 0 xoff: 0 yoff: 143
|
||||
105
|
||||
ln: 178, col: 0ln: 178, col: 1 xoff: 0 yoff: 143
|
||||
100
|
||||
ln: 178, col: 2 xoff: 0 yoff: 143
|
||||
97
|
||||
ln: 178, col: 3 xoff: 0 yoff: 143
|
||||
109
|
||||
ln: 178, col: 4 xoff: 0 yoff: 143
|
||||
110
|
||||
ln: 178, col: 5 xoff: 0 yoff: 143
|
||||
32
|
||||
ln: 178, col: 6 xoff: 0 yoff: 143
|
||||
ln: 178, col: 5 xoff: 0 yoff: 143
|
||||
ln: 178, col: 4 xoff: 0 yoff: 143
|
||||
ln: 178, col: 3 xoff: 0 yoff: 143
|
||||
ln: 178, col: 2 xoff: 0 yoff: 143
|
||||
ln: 178, col: 1 xoff: 0 yoff: 143
|
||||
ln: 178, col: 0 xoff: 0 yoff: 143
|
||||
ln: 177, col: 4 xoff: 0 yoff: 143
|
||||
ln: 178, col: 0 xoff: 0 yoff: 143
|
||||
105
|
||||
ln: 178, col: 1 xoff: 0 yoff: 143
|
||||
ln: 178, col: 0 xoff: 0 yoff: 143
|
||||
ln: 177, col: 4 xoff: 0 yoff: 143
|
||||
ln: 178, col: 0 xoff: 0 yoff: 143
|
||||
ln: 177, col: 4 xoff: 0 yoff: 143
|
||||
ln: 178, col: 0 xoff: 0 yoff: 143
|
||||
ln: 177, col: 4 xoff: 0 yoff: 143
|
||||
ln: 178, col: 0 xoff: 0 yoff: 143
|
||||
ln: 177, col: 0 xoff: 0 yoff: 143
|
||||
ln: 178, col: 0 xoff: 0 yoff: 143
|
||||
ln: 177, col: 4 xoff: 0 yoff: 143
|
||||
ln: 178, col: 0 xoff: 0 yoff: 143
|
||||
ln: 177, col: 4 xoff: 0 yoff: 143
|
||||
ln: 178, col: 0 xoff: 0 yoff: 143
|
||||
ln: 177, col: 4 xoff: 0 yoff: 143
|
||||
ln: 178, col: 0 xoff: 0 yoff: 143
|
||||
ln: 178, col: 0 xoff: 0 yoff: 143
|
||||
ln: 178, col: 0 xoff: 0 yoff: 143
|
||||
ln: 178, col: 0 xoff: 0 yoff: 143
|
||||
111
|
||||
ln: 178, col: 0ln: 178, col: 1 xoff: 0 yoff: 143
|
||||
ln: 177, col: 1 xoff: 0 yoff: 143
|
||||
ln: 176, col: 1 xoff: 0 yoff: 143
|
||||
ln: 175, col: 1 xoff: 0 yoff: 143
|
||||
410
|
||||
ln: 175, col: 2 xoff: 0 yoff: 143
|
||||
410
|
||||
ln: 175, col: 3 xoff: 0 yoff: 155
|
||||
ln: 175, col: 4 xoff: 0 yoff: 155
|
||||
ln: 175, col: 3 xoff: 0 yoff: 155
|
||||
ln: 175, col: 2 xoff: 0 yoff: 155
|
||||
ln: 175, col: 1 xoff: 0 yoff: 155
|
||||
ln: 175, col: 2 xoff: 0 yoff: 155
|
||||
ln: 174, col: 2 xoff: 0 yoff: 155
|
||||
ln: 175, col: 2 xoff: 0 yoff: 155
|
||||
ln: 176, col: 2 xoff: 0 yoff: 155
|
||||
ln: 176, col: 1 xoff: 0 yoff: 155
|
||||
ln: 176, col: 0 xoff: 0 yoff: 155
|
||||
ln: 175, col: 22 xoff: 0 yoff: 155
|
||||
ln: 176, col: 0 xoff: 0 yoff: 155
|
||||
ln: 176, col: 1 xoff: 0 yoff: 155
|
||||
ln: 176, col: 0 xoff: 0 yoff: 155
|
||||
ln: 175, col: 22 xoff: 0 yoff: 155
|
||||
@@ -1,213 +0,0 @@
|
||||
/// dynamic array class
|
||||
/// written by: Harry Irving
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct {
|
||||
uint32_t size, capacity;
|
||||
char* data;
|
||||
} String_t;
|
||||
|
||||
String_t str_with_capacity(int capacity) {
|
||||
String_t s;
|
||||
|
||||
/// allocate memory for 'capacity' chars
|
||||
s.data = (char*)calloc(capacity, sizeof(char));
|
||||
|
||||
s.size = 0;
|
||||
s.capacity = capacity;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
String_t str_from_chars(const char* string) {
|
||||
String_t s;
|
||||
|
||||
s.data = (char*)calloc(strlen(string), sizeof(char));
|
||||
strcpy(s.data, string);
|
||||
s.size = strlen(string);
|
||||
s.capacity = strlen(string);
|
||||
return s;
|
||||
}
|
||||
|
||||
String_t str_from_slice(const char* string, int len) {
|
||||
String_t s;
|
||||
|
||||
s.data = (char*)calloc(len, sizeof(char));
|
||||
strncpy(s.data, string, len);
|
||||
s.size = len;
|
||||
s.capacity = len;
|
||||
return s;
|
||||
}
|
||||
|
||||
String_t str_new() {
|
||||
return str_with_capacity(1);
|
||||
}
|
||||
|
||||
int str_dealloc(String_t* self) {
|
||||
free(self->data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int str_push(String_t* self, char c) {
|
||||
// check size < capacity
|
||||
if (self->size < self->capacity) {
|
||||
self->data[self->size] = c;
|
||||
self->size++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// reallocate to add capacity for an extra char
|
||||
int newcap = self->capacity + sizeof(char);
|
||||
self->data = (char*)realloc(self->data, newcap);
|
||||
self->data[self->size] = c;
|
||||
self->size++;
|
||||
self->capacity = newcap;
|
||||
return 0;
|
||||
}
|
||||
|
||||
char str_pop(String_t* self) {
|
||||
if (self->size == 0) {
|
||||
return '\0';
|
||||
}
|
||||
self->size--;
|
||||
char c = self->data[self->size];
|
||||
return c;
|
||||
}
|
||||
|
||||
int str_insert(String_t* self, int index, char c) {
|
||||
if (index > self->size) {
|
||||
return -1;
|
||||
}
|
||||
self->size++;
|
||||
for (int i = self->size - 1; i > index; i--) {
|
||||
self->data[i] = self->data[i - 1];
|
||||
}
|
||||
self->data[index] = c;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int str_remove(String_t* self, int index) {
|
||||
if (index >= self->size) {
|
||||
return -1;
|
||||
}
|
||||
self->size--;
|
||||
for (int i = index; i < self->size; i++) {
|
||||
self->data[i] = self->data[i + 1];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// splits a string into an array of strings based on a delimiter
|
||||
String_t* str_split(String_t* self, int* res_len, char c) {
|
||||
|
||||
char* string = self->data;
|
||||
String_t* elements = NULL;
|
||||
|
||||
// find the number of lines in the file
|
||||
|
||||
bool flag = false;
|
||||
*res_len = 0;
|
||||
for (int i = 0; i < strlen(string); i++) {
|
||||
if (string[i] == c) {
|
||||
if (flag) {
|
||||
(*res_len)++;
|
||||
flag = false;
|
||||
}
|
||||
} else {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
if (flag) {
|
||||
(*res_len)++;
|
||||
}
|
||||
|
||||
// allocate memory for an array of pointers to each line
|
||||
elements = (String_t*)malloc((*res_len) * sizeof(String_t));
|
||||
|
||||
int i = 0;
|
||||
flag = false;
|
||||
char* start = string;
|
||||
char* end = string;
|
||||
|
||||
while (*end != '\0') {
|
||||
if (*end == c) {
|
||||
if (flag) {
|
||||
elements[i] = str_from_slice(start, end - start);
|
||||
i++;
|
||||
}
|
||||
end++;
|
||||
start = end;
|
||||
flag = false;
|
||||
} else {
|
||||
end++;
|
||||
flag = true;
|
||||
}
|
||||
} if (flag) {
|
||||
elements[i] = str_from_slice(start, end - start);
|
||||
}
|
||||
|
||||
|
||||
// returns an array of String_t
|
||||
return elements;
|
||||
}
|
||||
|
||||
String_t str_merge(String_t* s1, String_t* s2) {
|
||||
String_t s;
|
||||
s.size = s1->size + s2->size;
|
||||
s.capacity = s.size;
|
||||
s.data = (char*)calloc(s.size, sizeof(char));
|
||||
for (int i = 0; i < s1->size; i++) {
|
||||
s.data[i] = s1->data[i];
|
||||
}
|
||||
for (int i = 0; i < s2->size; i++) {
|
||||
s.data[s1->size + i] = s2->data[i];
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
String_t* str_lines(String_t* self, int* numlines) {
|
||||
return str_split(self, numlines, '\n');
|
||||
}
|
||||
|
||||
String_t str_slice(String_t* s, int start, int end) {
|
||||
String_t s2;
|
||||
s2.size = end - start;
|
||||
s2.capacity = s2.size;
|
||||
s2.data = (char*)calloc(s2.size, sizeof(char));
|
||||
for (int i = 0; i < s2.size; i++) {
|
||||
s2.data[i] = s->data[start + i];
|
||||
}
|
||||
return s2;
|
||||
}
|
||||
|
||||
int str_len(String_t* s) {
|
||||
return s->size;
|
||||
}
|
||||
|
||||
char* to_chars(String_t* s) {
|
||||
return s->data;
|
||||
}
|
||||
|
||||
// int main() {
|
||||
// String_t s = str_from_chars("hello\nworld\neeeee\notherline\n");
|
||||
|
||||
// str_remove(&s, 10);
|
||||
// str_insert(&s, 10, 'h');
|
||||
|
||||
// printf("%s\n", to_chars(&s));
|
||||
|
||||
// int linen = 0;
|
||||
// String_t* lines = str_lines(&s, &linen);
|
||||
// for (int i=0; i < linen; i++) {
|
||||
// printf("%s", to_chars(&lines[i]));
|
||||
// }
|
||||
|
||||
// str_dealloc(&s);
|
||||
|
||||
// return 0;
|
||||
// }
|
||||
@@ -1,4 +0,0 @@
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user