├── temp ├── g ├── 1.png ├── 2.png ├── 3.png ├── 4.png ├── 5.png ├── 6.png └── 7.png ├── Code ├── Extra Files │ ├── end3.txt │ ├── end1.txt │ ├── end2.txt │ ├── Welcome2.txt │ ├── checking.txt │ ├── sademoji.txt │ ├── Welcome1.txt │ ├── D2.txt │ ├── D4.txt │ ├── invalid.txt │ ├── Credits1.txt │ ├── D3.txt │ ├── Exit.txt │ ├── Welcome4.txt │ ├── saved.txt │ ├── notsaved.txt │ ├── Welcome3.txt │ ├── D1.txt │ ├── exitmenu.txt │ ├── Exit1.txt │ ├── MenuTitle.txt │ ├── bye.txt │ └── Credits2.txt ├── Project.cpp ├── dictionary.txt ├── List.h ├── Trie.h ├── Project.vcxproj ├── MDList.h └── Notepad.h ├── README.md ├── LICENSE ├── Requirements.md └── TRIE Overview.md /temp/g: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Code/Extra Files/end3.txt: -------------------------------------------------------------------------------- 1 | _ 2 | / | 3 | | | _ _ 4 | |_| (_) (_) -------------------------------------------------------------------------------- /Code/Extra Files/end1.txt: -------------------------------------------------------------------------------- 1 | ____ 2 | |__ / 3 | |_ \ _ _ 4 | |___/ (_) (_) -------------------------------------------------------------------------------- /Code/Extra Files/end2.txt: -------------------------------------------------------------------------------- 1 | ___ 2 | |_ ) 3 | / / _ _ 4 | /___| (_) (_) -------------------------------------------------------------------------------- /temp/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HxnDev/Console-Based-Notepad-using-Trie-Trees/HEAD/temp/1.png -------------------------------------------------------------------------------- /temp/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HxnDev/Console-Based-Notepad-using-Trie-Trees/HEAD/temp/2.png -------------------------------------------------------------------------------- /temp/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HxnDev/Console-Based-Notepad-using-Trie-Trees/HEAD/temp/3.png -------------------------------------------------------------------------------- /temp/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HxnDev/Console-Based-Notepad-using-Trie-Trees/HEAD/temp/4.png -------------------------------------------------------------------------------- /temp/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HxnDev/Console-Based-Notepad-using-Trie-Trees/HEAD/temp/5.png -------------------------------------------------------------------------------- /temp/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HxnDev/Console-Based-Notepad-using-Trie-Trees/HEAD/temp/6.png -------------------------------------------------------------------------------- /temp/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HxnDev/Console-Based-Notepad-using-Trie-Trees/HEAD/temp/7.png -------------------------------------------------------------------------------- /Code/Extra Files/Welcome2.txt: -------------------------------------------------------------------------------- 1 | 2 | _ 3 | | |_ ___ 4 | | __/ _ \ 5 | | || (_) | 6 | \__\___/ 7 | 8 | -------------------------------------------------------------------------------- /Code/Project.cpp: -------------------------------------------------------------------------------- 1 | #include "Trie.h" 2 | #include "Notepad.h" 3 | int main() 4 | { 5 | 6 | Notepad n; 7 | n.RunAll(); //Runs all of the program 8 | 9 | } -------------------------------------------------------------------------------- /Code/Extra Files/checking.txt: -------------------------------------------------------------------------------- 1 | lets see if the code works or NOT. I hope it does lol fingers crossed. writing some random words now hapten listen pecked peck piper tension thats it BYE -------------------------------------------------------------------------------- /Code/Extra Files/sademoji.txt: -------------------------------------------------------------------------------- 1 | .-""""""-. 2 | .' '. 3 | / O O \ 4 | : ` : 5 | | | 6 | : .------. : 7 | \ ' ' / 8 | '. .' 9 | '-......-' -------------------------------------------------------------------------------- /Code/Extra Files/Welcome1.txt: -------------------------------------------------------------------------------- 1 | 2 | __ __ _ 3 | / / /\ \ \___| | ___ ___ _ __ ___ ___ 4 | \ \/ \/ / _ | |/ __/ _ \| '_ ` _ \ / _ \ 5 | \ /\ | __| | (_| (_) | | | | | | __/ 6 | \/ \/ \___|_|\___\___/|_| |_| |_|\___| 7 | 8 | -------------------------------------------------------------------------------- /Code/Extra Files/D2.txt: -------------------------------------------------------------------------------- 1 | __ _ _ ______ _ _ 2 | / | _ | \ | | | ___(_) | 3 | `| |(_) | \| | _____ __ | |_ _| | ___ 4 | | | | . ` |/ _ \ \ /\ / / | _| | | |/ _ \ 5 | _| |__ | |\ | __/\ V V / | | | | | __/ 6 | \___(_) \_| \_/\___| \_/\_/ \_| |_|_|\___| 7 | 8 | 9 | -------------------------------------------------------------------------------- /Code/Extra Files/D4.txt: -------------------------------------------------------------------------------- 1 | ___ _ _ _ _ __ 2 | / __| ___| |___ __| |_ _ _ ___ _ _ _ _ ___ _ __| |_(_)___ _ _ __\ \ 3 | \__ \/ -_) / -_) _| _| | || / _ \ || | '_| / _ \ '_ \ _| / _ \ ' \ |___> > 4 | |___/\___|_\___\__|\__| \_, \___/\_,_|_| \___/ .__/\__|_\___/_||_| /_/ 5 | |__/ |_| 6 | -------------------------------------------------------------------------------- /Code/Extra Files/invalid.txt: -------------------------------------------------------------------------------- 1 | 2 | ___ _ _ _ ___ _ _ 3 | |_ _|_ ____ ____ _| (_) __| | / _ \ _ __ | |_(_) ___ _ __ 4 | | || '_ \ \ / / _` | | |/ _` | | | | | '_ \| __| |/ _ \| '_ \ 5 | | || | | \ V / (_| | | | (_| | | |_| | |_) | |_| | (_) | | | | 6 | |___|_| |_|\_/ \__,_|_|_|\__,_| \___/| .__/ \__|_|\___/|_| |_| 7 | |_| 8 | -------------------------------------------------------------------------------- /Code/Extra Files/Credits1.txt: -------------------------------------------------------------------------------- 1 | ___ 2 | ( ) 3 | | |.-. ___ ___ 4 | | / \ ( )( ) 5 | | .-. | | | | | .-. 6 | | | | | | | | | ( ) 7 | | | | | | ' | | `-' 8 | | | | | ' `-' | .-. 9 | | ' | | `.__. | ( ) 10 | ' `-' ; ___ | | `-' 11 | `.__. ( )' | 12 | ; `-' ' 13 | .__.' 14 | -------------------------------------------------------------------------------- /Code/Extra Files/D3.txt: -------------------------------------------------------------------------------- 1 | _____ _____ _ _ _ ______ _ _ 2 | / __ \ _ | ___| (_) | | (_) | ___(_) | 3 | `' / /'(_) | |____ ___ ___| |_ _ _ __ __ _ | |_ _| | ___ 4 | / / | __\ \/ / / __| __| | '_ \ / _` | | _| | | |/ _ \ 5 | ./ /___ _ | |___> <| \__ \ |_| | | | | (_| | | | | | | __/ 6 | \_____/(_) \____/_/\_\_|___/\__|_|_| |_|\__, | \_| |_|_|\___| 7 | __/ | 8 | |___/ 9 | -------------------------------------------------------------------------------- /Code/Extra Files/Exit.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | ___ _ _ _ _ _ ___ 4 | | \ ___ _ _ ___ _ _ __ __ _(_)__| |_ | |_ ___ _____ _(_) ||__ \ 5 | | |) / _ \ | || / _ \ || | \ V V / (_-< ' \ | _/ _ \ / -_) \ / | _|/_/ 6 | |___/\___/ \_, \___/\_,_| \_/\_/|_/__/_||_| \__\___/ \___/_\_\_|\__(_) 7 | |__/ 8 | 9 | _ ___ 10 | /_\ _ _ ___ _ _ ___ _ _ ____ _ _ _ __|__ \ 11 | / _ \| '_/ -_) | || / _ \ || | (_-< || | '_/ -_)/_/ 12 | /_/ \_\_| \___| \_, \___/\_,_| /__/\_,_|_| \___(_) 13 | |__/ 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Console-Based-Notepad-using-Trie-Trees 2 | 3 | There are 4 header files and 1 cpp file. 4 | 5 | Header files are as follows: 6 | List.h, MDList.h, Notepad.h, Trei.h 7 | 8 | All the files have been commented for your ease. Furthermore you may also add further comments if you may. I have uploaded the Visual Studio project file too. You can simply run the project by running "Assignment 2.vcxproj". 9 | 10 | #### Furthermore all text files are simply some additional work that we did 11 | 12 | For better understanding of the scenerio, refer to "Requirements.md" and "TRIE Overview.pdf". 13 | 14 | This was a group project and equal contribution was provided by my fellow team member [Azka Khurram](https://github.com/AzkaKhurram) 15 | 16 | For further queries contact me at : chhxnshah@gmail.com 17 | -------------------------------------------------------------------------------- /Code/Extra Files/Welcome4.txt: -------------------------------------------------------------------------------- 1 | ___ 2 | ( ) 3 | .-.. ___ .-. .--. .-. .--. .--. | |_ 4 | / \ ( ) \ / \ ( __) / \ / \ ( __) 5 | ' .-, ; | ' .-. ; | .-. ; (''") | .-. ; | .-. ; | | 6 | | | . | | / (___) | | | | | | | | | | | |(___) | | ___ 7 | | | | | | | | | | | | | | |/ | | | | |( ) 8 | | | | | | | | | | | | | | ' _.' | | ___ | | | | 9 | | | ' | | | | ' | | | | | .'.-. | '( ) | ' | | 10 | | `-' ' | | ' `-' / ___ | | ' `-' / ' `-' | ' `-' ; 11 | | \__.' (___) `.__.' ( )' | `.__.' `.__,' `.__. 12 | | | ; `-' ' 13 | (___) .__.' 14 | -------------------------------------------------------------------------------- /Code/Extra Files/saved.txt: -------------------------------------------------------------------------------- 1 | 2 | ________ _____ __ 3 | / ____/ /_ ____ _____ ____ ____ _____ / ___/____ __ _____ ____/ / 4 | / / / __ \/ __ `/ __ \/ __ `/ _ \/ ___/ \__ \/ __ `/ | / / _ \/ __ / 5 | / /___/ / / / /_/ / / / / /_/ / __(__ ) ___/ / /_/ /| |/ / __/ /_/ / 6 | \____/_/ /_/\__,_/_/ /_/\__, /\___/____/ /____/\__,_/ |___/\___/\__,_/ 7 | /____/ 8 | 9 | 10 | _____ _ _ _ _ _ _ 11 | |_ _| |_ ___ _ __ _ _ ___ __ _ _ _ __ _ _ __ __ __ _(_) | | ___ _ _ __| | (_)_ _ 12 | | | | ' \/ -_) | '_ \ '_/ _ \/ _` | '_/ _` | ' \ \ V V / | | | / -_) ' \/ _` | | | ' \ _ _ 13 | |_| |_||_\___| | .__/_| \___/\__, |_| \__,_|_|_|_| \_/\_/|_|_|_| \___|_||_\__,_| |_|_||_(_|_) 14 | |_| |___/ 15 | 16 | -------------------------------------------------------------------------------- /Code/Extra Files/notsaved.txt: -------------------------------------------------------------------------------- 1 | ________ _ __ __ _____ __ 2 | / ____/ /_ ____ _____ ____ ____ _____ / | / /___ / /_ / ___/____ __ _____ ____/ / 3 | / / / __ \/ __ `/ __ \/ __ `/ _ \/ ___/ / |/ / __ \/ __/ \__ \/ __ `/ | / / _ \/ __ / 4 | / /___/ / / / /_/ / / / / /_/ / __(__ ) / /| / /_/ / /_ ___/ / /_/ /| |/ / __/ /_/ / 5 | \____/_/ /_/\__,_/_/ /_/\__, /\___/____/ /_/ |_/\____/\__/ /____/\__,_/ |___/\___/\__,_/ 6 | /____/ 7 | 8 | _____ _ _ _ _ _ _ 9 | |_ _| |_ ___ _ __ _ _ ___ __ _ _ _ __ _ _ __ __ __ _(_) | | ___ _ _ __| | (_)_ _ 10 | | | | ' \/ -_) | '_ \ '_/ _ \/ _` | '_/ _` | ' \ \ V V / | | | / -_) ' \/ _` | | | ' \ _ _ 11 | |_| |_||_\___| | .__/_| \___/\__, |_| \__,_|_|_|_| \_/\_/|_|_|_| \___|_||_\__,_| |_|_||_(_|_) 12 | |_| |___/ 13 | 14 | -------------------------------------------------------------------------------- /Code/Extra Files/Welcome3.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | DDDDDDDDDDDDD SSSSSSSSSSSSSSS 5 | D::::::::::::DDD SS:::::::::::::::S 6 | D:::::::::::::::DD S:::::SSSSSS::::::S 7 | DDD:::::DDDDD:::::D S:::::S SSSSSSS 8 | D:::::D D:::::DS:::::S 9 | D:::::D D:::::S:::::S 10 | D:::::D D:::::DS::::SSSS 11 | D:::::D D:::::D SS::::::SSSSS 12 | D:::::D D:::::D SSS::::::::SS 13 | D:::::D D:::::D SSSSSS::::S 14 | D:::::D D:::::D S:::::S 15 | D:::::D D:::::D S:::::S 16 | DDD:::::DDDDD:::::D SSSSSSS S:::::S 17 | D:::::::::::::::DD S::::::SSSSSS:::::S 18 | D::::::::::::DDD S:::::::::::::::SS 19 | DDDDDDDDDDDDD SSSSSSSSSSSSSSS 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Hassan Shahzad 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Code/Extra Files/D1.txt: -------------------------------------------------------------------------------- 1 | 2 | _____ ___ _ _ ___ __ __ ____ ____ ____ ____ ____ ___ ______ __ __ ___ ___ ____ ______ ____ ___ ____ _____ 3 | | | / \ | | | | / \ | |__| || || \ / | / || \ / _] | || | | / _] / \ | \| || |/ \ | \ / ___/ __ 4 | | __|| || | | | | || | | | | | | _ || __| | o || D ) / [_ | || | | / [_ | || o ) | | || || _ ( \_ | | 5 | | |_ | O || |___ | |___ | O || | | | | | | | || | | | || / | _] |_| |_|| _ || _] | O || _/|_| |_| | || O || | |\__ | |__| 6 | | _] | || || || || ` ' | | | | | || |_ | | _ || \ | [_ | | | | || [_ | || | | | | || || | |/ \ | __ 7 | | | | || || || | \ / | | | | || | | | || . \| | | | | | || | | || | | | | || || | |\ | | | 8 | |__| \___/ |_____||_____| \___/ \_/\_/ |____||__|__||___,_| |__|__||__|\_||_____| |__| |__|__||_____| \___/ |__| |__| |____|\___/ |__|__| \___| |__| 9 | 10 | -------------------------------------------------------------------------------- /Code/Extra Files/exitmenu.txt: -------------------------------------------------------------------------------- 1 | _____ ____ __ ______ _ _ __ __ _ _ _______ _______ ____ _____ __ ________ _______ _ _ ______ _____ _ _ _ _ _____ ______ _____ ___ 2 | | __ \ / __ \ \ \ / / __ \| | | | \ \ / /\ | \ | |__ __| |__ __/ __ \ / ____| /\ \ / / ____| |__ __| | | | ____| / ____| | | | /\ | \ | |/ ____| ____|/ ____|__ \ 3 | | | | | | | | \ \_/ / | | | | | | \ \ /\ / / \ | \| | | | | | | | | | | (___ / \ \ / /| |__ | | | |__| | |__ | | | |__| | / \ | \| | | __| |__ | (___ ) | 4 | | | | | | | | \ /| | | | | | | \ \/ \/ / /\ \ | . ` | | | | | | | | | \___ \ / /\ \ \/ / | __| | | | __ | __| | | | __ | / /\ \ | . ` | | |_ | __| \___ \ / / 5 | | |__| | |__| | | | | |__| | |__| | \ /\ / ____ \| |\ | | | | | | |__| | ____) / ____ \ / | |____ | | | | | | |____ | |____| | | |/ ____ \| |\ | |__| | |____ ____) ||_| 6 | |_____/ \____/ |_| \____/ \____/ \/ \/_/ \_\_| \_| |_| |_| \____/ |_____/_/ \_\/ |______| |_| |_| |_|______| \_____|_| |_/_/ \_\_| \_|\_____|______|_____/ (_) 7 | 8 | 9 | -------------------------------------------------------------------------------- /Code/Extra Files/Exit1.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | .--. ___ ___ .--. .--. .--. ___ .-. .--. 5 | (_ | ( )( ) / \ / _ \ ; _ \ ( ) \ / \ 6 | | | .-. | | | | | .-. ; . .' `. ; (___)` | .-. | .-. . | .-. ; 7 | | | ( ) | | | | | | | | | ' | | ' ' ( ) | | | | | | | | 8 | | | `-' | ' | | | |/ | _\_`.(___) / / `-' | | | | | | | | 9 | | | .-. ' `-' | | ' _.' ( ). '. / / .-. | | | | | | | | 10 | | | ( ) `.__. | | .'.-. | | `\ | / / ( ) | | | | | ' | | 11 | | | `-' ___ | | ' `-' / ; '._,' ' / '____ `-' | | | | ' `-' / 12 | (___) ( )' | `.__.' '.___.' (_______) (___)(___) `.__.' 13 | ; `-' ' 14 | .__.' 15 | -------------------------------------------------------------------------------- /Code/dictionary.txt: -------------------------------------------------------------------------------- 1 | -piper 2 | --a person who plays a pipe, especially an itinerant musician. 3 | betel 4 | cubeb vine 5 | decot genus 6 | java pepper 7 | piperaceae 8 | -picked 9 | --take hold of and remove (a flower, fruit, or vegetable) from where it is growing. 10 | take 11 | hand-pick 12 | select 13 | choose 14 | -peck 15 | --a stroke or bite by a bird with its beak. 16 | strike 17 | beak 18 | pick 19 | -pecked 20 | --(of a bird) strike or bite something with its beak. 21 | strike 22 | beak 23 | pick 24 | -pickled 25 | --(of food) preserved in vinegar or brine. 26 | glazed 27 | bashed 28 | potted 29 | sloshed 30 | laced 31 | -peppers 32 | --a pungent, hot-tasting powder prepared from dried and ground peppercorns. 33 | pelt 34 | attack 35 | throw 36 | assail 37 | -silent 38 | --not making or accompanied by any sound. 39 | completely quiet 40 | still 41 | hushed 42 | inaudible 43 | noiseless 44 | -listen 45 | --give one's attention to a sound. 46 | hear 47 | pay attention 48 | be attentive 49 | attend 50 | concentrate on 51 | -zooid 52 | --an animal arising from another by budding or division 53 | being 54 | organism 55 | -zoetrope 56 | --a cylinder with a series of pictures on the inner surface 57 | glamping 58 | hygge 59 | -hapten 60 | --a substance having a single antigenic determinant that can react with a previously existing antibody 61 | substance 62 | -theatrical 63 | --relating to acting, actors, or the theatre 64 | stage 65 | show 66 | -ownership 67 | --the act, state, or right of possessing something 68 | possesion 69 | freehold 70 | -tension 71 | --mental or emotional strain 72 | stress 73 | anxiety 74 | pressure 75 | tightness 76 | -poetic 77 | --relating to or used in poetry 78 | expressive 79 | aesthetic 80 | verse 81 | lyric 82 | -preventable 83 | --capable of being prevented 84 | avoidable 85 | -hopeless 86 | --providing no hope; beyond optimism or hope 87 | not desperate 88 | without hope -------------------------------------------------------------------------------- /Code/Extra Files/MenuTitle.txt: -------------------------------------------------------------------------------- 1 | .-----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. __ __ __ __ __ 2 | | .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. | |__|__|__|__|__|__|__|__|__|__ 3 | | | ____ _____ | || | ____ | || | _________ | || | _________ | || | ______ | || | __ | || | ________ | | / / 4 | | ||_ \|_ _| | || | .' `. | || | | _ _ | | || | |_ ___ | | || | |_ __ \ | || | / \ | || | |_ ___ `. | | __ / |- - - - - - - - - - - - - -/ 5 | | | | \ | | | || | / .--. \ | || | |_/ | | \_| | || | | |_ \_| | || | | |__) | | || | / /\ \ | || | | | `. \ | | \ \ /- - - - - - - - - - - - / 6 | | | | |\ \| | | || | | | | | | || | | | | || | | _| _ | || | | ___/ | || | / ____ \ | || | | | | | | | \ \ /- - - - - - - - - - - - - - / 7 | | | _| |_\ |_ | || | \ `--' / | || | _| |_ | || | _| |___/ | | || | _| |_ | || | _/ / \ \_ | || | _| |___.' / | | \ \ /- - - - - - - - - - - - / 8 | | ||_____|\____| | || | `.____.' | || | |_____| | || | |_________| | || | |_____| | || ||____| |____|| || | |________.' | | \ \ /- - - - - - - - - - - - - - / 9 | | | | || | | || | | || | | || | | || | | || | | | \_\ / - - - - - - - - - - / 10 | | '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' | \/ / / 11 | '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' / / 12 | / / 13 | /_____________________________/ -------------------------------------------------------------------------------- /Code/Extra Files/bye.txt: -------------------------------------------------------------------------------- 1 | 2 | BBBBBBBBBBBBBBBBB 3 | B::::::::::::::::B 4 | B::::::BBBBBB:::::B 5 | BB:::::B B:::::B 6 | B::::B B:::::Byyyyyyy yyyyyyy eeeeeeeeeeee 7 | B::::B B:::::B y:::::y y:::::yee::::::::::::ee 8 | B::::BBBBBB:::::B y:::::y y:::::ye::::::eeeee:::::ee 9 | B:::::::::::::BB y:::::y y:::::ye::::::e e:::::e 10 | B::::BBBBBB:::::B y:::::y y:::::y e:::::::eeeee::::::e 11 | B::::B B:::::B y:::::y y:::::y e:::::::::::::::::e 12 | B::::B B:::::B y:::::y:::::y e::::::eeeeeeeeeee 13 | B::::B B:::::B y:::::::::y e:::::::e 14 | BB:::::BBBBBB::::::B y:::::::y e::::::::e 15 | B:::::::::::::::::B y:::::y e::::::::eeeeeeee 16 | B::::::::::::::::B y:::::y ee:::::::::::::e 17 | BBBBBBBBBBBBBBBBB y:::::y eeeeeeeeeeeeee 18 | y:::::y 19 | y:::::y 20 | y:::::y 21 | y:::::y 22 | yyyyyyy 23 | 24 | 25 | __ooooooooo__ 26 | oOOOOOOOOOOOOOOOOOOOOOo 27 | oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo 28 | oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo 29 | oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo 30 | oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo 31 | oOOOOOOOOOOO* *OOOOOOOOOOOOOO* *OOOOOOOOOOOOo 32 | oOOOOOOOOOOO OOOOOOOOOOOO OOOOOOOOOOOOo 33 | oOOOOOOOOOOOOo oOOOOOOOOOOOOOOo oOOOOOOOOOOOOOo 34 | oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo 35 | oOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOo 36 | oOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOo 37 | *OOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOO* 38 | *OOOOOO *OOOOOOOOOOOOOOOOOOOOOOOOOOOOO* OOOOOO* 39 | *OOOOOO *OOOOOOOOOOOOOOOOOOOOOOOOOOO* OOOOOO* 40 | *OOOOOOo *OOOOOOOOOOOOOOOOOOOOOOO* oOOOOOO* 41 | *OOOOOOOo *OOOOOOOOOOOOOOOOO* oOOOOOOO* 42 | *OOOOOOOOo *OOOOOOOOOOO* oOOOOOOOO* 43 | *OOOOOOOOo oOOOOOOOO* 44 | *OOOOOOOOOOOOOOOOOOOOO* 45 | ""ooooooooo"" -------------------------------------------------------------------------------- /Code/Extra Files/Credits2.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | ,----, ,--. ,--. ,--, ,--. 4 | ,---, .' .`| ,--/ /| ,---, ,---, ,--.'| ,---, ,--.'| ,---, .--.--. .--.--. ,---, ,--.'| 5 | ' .' \ .' .' ;,---,': / ' ' .' \ ' .' \ ,--,: : | .' .' `\ ,--, | : ' .' \ / / '. / / '. ' .' \ ,--,: : | 6 | / ; '. ,---, ' .': : '/ / / ; '. / ; '. ,`--.'`| ' :,---.' \ ,---.'| : ' / ; '. | : /`. /| : /`. / / ; '. ,`--.'`| ' : 7 | : : \ | : ./ | ' , : : \ : : \ | : : | || | .`\ | | | : _' |: : \ ; | |--` ; | |--` : : \ | : : | | 8 | : | /\ \ ; | .' / ' | / : | /\ \ : | /\ \ : | \ | :: : | ' | : : |.' |: | /\ \| : ;_ | : ;_ : | /\ \ : | \ | : 9 | | : ' ;. :`---' / ; | ; ; | : ' ;. : | : ' ;. : | : ' '; || ' ' ; : | ' ' ; :| : ' ;. :\ \ `. \ \ `. | : ' ;. : | : ' '; | 10 | | | ;/ \ \ / ; / : ' \ | | ;/ \ \ | | ;/ \ \' ' ;. ;' | ; . | ' | .'. || | ;/ \ \`----. \ `----. \| | ;/ \ \' ' ;. ; 11 | ' : | \ \ ,'; / /--, | | ' ' : | \ \ ,' ' : | \ \ ,'| | | \ || | : | ' | | : | '' : | \ \ ,'__ \ \ | __ \ \ |' : | \ \ ,'| | | \ | 12 | | | ' '--' / / / .`| ' : |. \| | ' '--' | | ' '--' ' : | ; .'' : | / ; ' : | : ;| | ' '--' / /`--' // /`--' /| | ' '--' ' : | ; .' 13 | | : : ./__; : | | '_\.'| : : | : : | | '`--' | | '` ,/ | | ' ,/ | : : '--'. /'--'. / | : : | | '`--' 14 | | | ,' | : .' ' : | | | ,' | | ,' ' : | ; : .' ; : ;--' | | ,' `--'---' `--'---' | | ,' ' : | 15 | `--'' ; | .' ; |,' `--'' `--'' ; |.' | ,.' | ,/ `--'' `--'' ; |.' 16 | `---' '---' '---' '---' '---' '---' 17 | 18 | -------------------------------------------------------------------------------- /Requirements.md: -------------------------------------------------------------------------------- 1 | # Develop a Console Based Notepad Application Supported by Trie Tree 2 | 3 | Create a notepad that allows the user to write text on the console. For this purpose, 4 | the user should be able to control and track the movement of the cursor. The user 5 | should be able to navigate to any part of console (cursor control) in order to 6 | perform any insertion or deletion of words. 7 | 8 | - Upon execution, the program should display a menu prompting the user to 9 | either create a new text file or load an existing text file. 10 | - To delete text, user would press "BackSpace" button. 11 | - To fetch meaning and synonyms of an entered word, when cursor is right 12 | at end of word (identified by punctuation like dot (.), comma (,), semi- 13 | colon (;), colon (:), or spacebar. 14 | - To quit notepad, user would press “Esc” button. Program should ask user 15 | to enter name of the file. 16 | - To add or delete some text, the user can take the cursor to that location 17 | (using the arrow keys) and perform the required operation (to insert or 18 | delete the word). Insertion, deletion, updating & cursor movement 19 | functionality should be exactly similar to that of Notepad application. 20 | - If you close the program, you should free up all memory occupied by 21 | linked list. 22 | - You should partition your console screen into 2 distinct segments. One for 23 | writing text in a notepad (75% of the screen) and one for displaying the 24 | meaning and synonyms of the entered word (25% of the screen). This is 25 | the same idea that is used in Visual Studio. Most of the screen is reserved 26 | for writing code but some part of it is reserved for displaying error list. 27 | 28 | Internally, the notepad is composed of four-dimensional linked list (every node 29 | should comprise of data element and 4 pointers for navigating left, right, up, and 30 | down). Its implementation is just like a doubly linked list with an additional 31 | property that it can grow in two dimensions. Since text can be written on multiple 32 | 33 | 34 | lines, each row of the 4D linked list represents one line. Each line is terminated 35 | when a newline is inserted in the ADT. 36 | 37 | Each node contains four links which it uses to connect to the node before, 38 | after, below and above it. In addition each node can store a character. Two 39 | words must be differentiated with a space character. 40 | 41 | ``` 42 | YOU ARE NOT ALLOWED TO DECLARE ANY ARRAY OF ANY KIND 43 | FOR ANY REASON. WHENEVER SUCH FUNCTIONALITY IS 44 | DESIRED, USE LINKED LISTS. 45 | ``` 46 | 47 | ## Trie Tree: 48 | You have to implement the functionality of dictionary too. 49 | 50 | 1. Load the dictionary words from text file (provided to you), construct a Trie 51 | tree from alphabets of loaded words. 52 | 2. Later on whatever word the user enters (terminated by punctuation like dot 53 | (.), comma (,), semicolon (;), colon (:), or spacebar), the word itself, its 54 | meaning and synonyms should be displayed in 25% screen portion using 55 | traversal of Trie tree (directly loading such items from text file and 56 | displaying is not allowed). 57 | 3. If the entered word (e.g., traye) does not exist in dictionary and thus can’t 58 | be located by traversing the Trie tree, an error message “-traye -- word 59 | does not exist” should be displayed in 25% screen portion. 60 | 4. Upon pressing Esc key, the Trie tree should also be destroyed by freeing 61 | the occupied memory. 62 | 63 | ### Hint 64 | – Use Window.h, or any other header file for cursor movement (navigation). 65 | Students have to learn and implement Cursor navigation control themselves 66 | without consulting instructors. Cursor movement sample code is also attached. 67 | 68 | 69 | -------------------------------------------------------------------------------- /Code/List.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | 8 | 9 | template 10 | struct node 11 | { 12 | node* next; 13 | T data; 14 | }; 15 | 16 | template 17 | 18 | class List 19 | { 20 | private: 21 | node* head; 22 | node* tail; 23 | node* current; 24 | int size; 25 | public: 26 | List() //Constructor 27 | { 28 | head = NULL; 29 | tail = NULL; 30 | current = NULL; 31 | size = 0; 32 | } 33 | 34 | 35 | void InsertFirst(T dataItem) //Inserts at the start of the list 36 | { 37 | node* newnode = new node; 38 | newnode->data = dataItem; 39 | newnode->next = head; 40 | head = newnode; 41 | size++; 42 | } 43 | 44 | 45 | void InsertLast(T dataItem) //Inserts at the end of the list 46 | { 47 | node* newnode = new node; 48 | 49 | newnode->data = dataItem; 50 | newnode->next = NULL; 51 | if (head == NULL) 52 | { 53 | head = newnode; 54 | tail = newnode; 55 | newnode = NULL; 56 | } 57 | else 58 | { 59 | tail->next = newnode; 60 | tail = newnode; 61 | } 62 | 63 | size++; 64 | } 65 | 66 | 67 | int returnIndex(const T& DataItem) //Returns index(position) of the node 68 | { 69 | node* current = head; 70 | int index = 1; 71 | 72 | while (current && current->data != DataItem) 73 | { 74 | current = current->next; 75 | index++; 76 | } 77 | 78 | if (current) 79 | return index - 1; 80 | return 0; 81 | } 82 | 83 | 84 | void removeFirst() //Removes at the start of the list 85 | { 86 | node* temp = new node; 87 | temp = head; 88 | head = head->next; 89 | delete temp; 90 | } 91 | 92 | 93 | void removeLast() //Removes the element from the end of the list 94 | { 95 | node* current = new node; 96 | node* previous = new node; 97 | current = head; 98 | while (current->next != NULL) 99 | { 100 | previous = current; 101 | current = current->next; 102 | } 103 | tail = previous; 104 | previous->next = NULL; 105 | delete current; 106 | } 107 | 108 | 109 | void remove(T DT) { //removes a data item 110 | if (head->data == DT) 111 | { 112 | removeFirst(); 113 | return; 114 | } 115 | 116 | if (tail->data == DT) 117 | { 118 | removeLast(); 119 | return; 120 | } 121 | 122 | node* current2 = head; 123 | node* temp = current2; 124 | 125 | while (current2 != NULL) 126 | { 127 | if (current2->data == DT) 128 | { 129 | temp->next = current2->next; 130 | delete current2; 131 | return; 132 | } 133 | 134 | else 135 | { 136 | temp = current2; 137 | current2 = current2->next; 138 | } 139 | } 140 | 141 | cout << "Item not found in list" << endl; 142 | } 143 | 144 | 145 | void Display() //Displays the list 146 | { 147 | node* newnode = new node; 148 | newnode = head; 149 | while (newnode != NULL) 150 | { 151 | cout << newnode->data; 152 | newnode = newnode->next; 153 | cout << "\n"; 154 | 155 | } 156 | } 157 | 158 | 159 | 160 | 161 | bool isEmpty() { //Checks if the list is empty 162 | if (!size) 163 | return true; 164 | 165 | return false; 166 | } 167 | 168 | 169 | int getSize() { //total size of list 170 | return size; 171 | } 172 | 173 | 174 | void clear() { //clears memory used by list 175 | node* current2 = head; 176 | node* temp = current2; 177 | 178 | while (current2 != NULL) 179 | { 180 | current2 = current2->next; 181 | delete temp; 182 | temp = current2; 183 | } 184 | 185 | size = 0; 186 | } 187 | 188 | 189 | T findVal(int index) { //Returns value at a given index 190 | 191 | node* current = head; 192 | int count = 0; 193 | 194 | while (current && count < index) { 195 | current = current->next; 196 | count++; 197 | } 198 | 199 | if (current == NULL) { 200 | cout << "\nIndex is out of range.\n"; 201 | } 202 | else 203 | return current->data; 204 | } 205 | 206 | 207 | T operator [](int index) { //Overloads '[]' operator 208 | return findVal(index); 209 | } 210 | 211 | 212 | ~List() //Destructor 213 | { 214 | node* current2 = head; 215 | node* temp = current2; 216 | 217 | while (current2 != NULL) 218 | { 219 | current2 = current2->next; 220 | delete temp; 221 | temp = current2; 222 | } 223 | } 224 | 225 | 226 | }; 227 | -------------------------------------------------------------------------------- /Code/Trie.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "List.h" 4 | 5 | template 6 | struct TrieNode 7 | { 8 | public: 9 | 10 | List synonyms; //vector to store synonyms 11 | string meaning; //stores Meanings 12 | TrieNode* arr[26]; 13 | bool Flag; //Returns 0 or 1 14 | T value; //Stores values 15 | int synCount; //Number of synonyms 16 | 17 | }; 18 | 19 | //-----------------// 20 | //----Trie Class---// 21 | //-----------------// 22 | 23 | class TRIE 24 | { 25 | private: 26 | TrieNode* root; //Root of the Dictionary 27 | string data; //String type data 28 | 29 | public: 30 | 31 | TRIE() //Constructor 32 | { 33 | root = NULL; 34 | } 35 | 36 | 37 | ~TRIE() //Destructor 38 | { 39 | delete root; 40 | } 41 | 42 | 43 | TrieNode* create(char x) //Creates a new node 44 | { 45 | TrieNode* newNode = new TrieNode; 46 | for (int i = 0; i < 26; ++i) 47 | { 48 | newNode->arr[i] = NULL; 49 | } 50 | newNode->Flag = 0; 51 | newNode->value = x; 52 | return newNode; 53 | } 54 | 55 | 56 | void CreateDictionary(string s) //Creates a dictionary .... 's' is the name of the file 57 | { 58 | TrieNode* rootNode = new TrieNode; //temporary root node 59 | rootNode->value = ' '; 60 | for (int i = 0; i < 26; i++) 61 | { 62 | rootNode->arr[i] = nullptr; 63 | rootNode->Flag = 0; 64 | } 65 | root = rootNode; 66 | fstream in; 67 | string s1; 68 | 69 | in.open(s.c_str(), ios::in); //opens the file 70 | if (!in) //if file does not open 71 | { 72 | cout << "File could not be opened\n"; 73 | exit(0); 74 | } 75 | int synCount = 0; 76 | int place; //temporary variable counting the location of a node 77 | 78 | 79 | TrieNode* newNode = root; 80 | TrieNode* temp = newNode; 81 | 82 | while (getline(in, s1)) 83 | { 84 | int len; 85 | if (s1[0] == '-' && s1[1] != '-') //Checks for a word 86 | { 87 | synCount = 0; 88 | len = s1.length(); 89 | newNode = root; 90 | 91 | for (int i = 1; i< len; i++) //We'll start from first index because of '-' 92 | { 93 | place = s1[i] % 97; 94 | 95 | if (newNode->arr[place] == NULL) 96 | { 97 | newNode->arr[place] = create(s1[i]); 98 | } 99 | newNode = newNode->arr[place]; 100 | } 101 | newNode->Flag = 1; 102 | } 103 | 104 | else if (s1[0] == '-' && s1[1] == '-') //Checks for Meaning 105 | { 106 | int len = s1.length(); 107 | for (int i = 2; i < len; i++) 108 | { 109 | s1[i - 2] = s1[i]; 110 | } 111 | string s2 = ""; 112 | s1[len - 2] = '\0'; 113 | for (int j = 0; s1[j] != '\0'; j++) 114 | { 115 | s2 += s1[j]; 116 | } 117 | newNode->meaning = s2; //Storing the meaning in each node 118 | } 119 | 120 | else //Checks for synonyms 121 | { 122 | if (newNode->Flag) 123 | { 124 | newNode->synonyms.InsertLast(s1); //Inserting the synonyms into the lists 125 | ++synCount; 126 | } 127 | } 128 | temp = newNode; 129 | } 130 | in.close(); //Closing File 131 | } 132 | 133 | 134 | bool FindWord(string s) //Returns true if the word is present 135 | { 136 | TrieNode* temproot; 137 | temproot = root; 138 | int len = s.length(); 139 | 140 | //cout << s; 141 | //cout << len; 142 | /*for (int x = 0; x < len; ++x) 143 | { 144 | cout << s[x] << "$"; 145 | }*/ 146 | int place; 147 | for (int x = 0; x < len; ++x) { 148 | place = s[x] % 97; 149 | if (temproot->arr[place] == NULL) 150 | { 151 | return 0; 152 | } 153 | temproot = temproot->arr[place]; 154 | } 155 | if (temproot != NULL && temproot->Flag == 1) 156 | { 157 | return 1; 158 | } 159 | return 0; 160 | } 161 | 162 | 163 | TrieNode* FindNode(string s) //Finds a specific data in a node and returns that node if found 164 | { 165 | TrieNode* temproot; 166 | temproot = root; 167 | int len = s.length(); 168 | int place; 169 | for (int x = 0; x < len; ++x) 170 | { 171 | place = s[x] % 97; 172 | if (!temproot->arr[place]) 173 | { 174 | return NULL; 175 | } 176 | temproot = temproot->arr[place]; 177 | } 178 | if (temproot != NULL && temproot->Flag == 1) 179 | { 180 | return temproot; 181 | } 182 | return NULL; 183 | 184 | } 185 | 186 | 187 | string FindMeaning(string s) //Finds meanings of the words 188 | { 189 | TrieNode* temp; 190 | temp = FindNode(s); 191 | if (temp == NULL) //if word is not found, then it will display "s-not found" 192 | { 193 | string str = s; 194 | str += "-Not Found\n"; 195 | return str; 196 | } 197 | else 198 | return temp->meaning; 199 | 200 | } 201 | 202 | 203 | List& FindSynonyms(string s) //Finds synonyms and returns list of printers 204 | { 205 | TrieNode * temp = FindNode(s); //Find the node 206 | return temp->synonyms; 207 | } 208 | }; 209 | -------------------------------------------------------------------------------- /Code/Project.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | {AECB627A-F730-48A0-9A7A-D4513414BE1F} 24 | Win32Proj 25 | Project 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v142 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v142 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v142 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v142 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | 76 | 77 | true 78 | 79 | 80 | false 81 | 82 | 83 | false 84 | 85 | 86 | 87 | 88 | 89 | Level3 90 | true 91 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 92 | true 93 | 94 | 95 | Console 96 | true 97 | 98 | 99 | 100 | 101 | 102 | 103 | Level3 104 | true 105 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 106 | true 107 | 108 | 109 | Console 110 | true 111 | 112 | 113 | 114 | 115 | 116 | 117 | Level3 118 | true 119 | true 120 | true 121 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 122 | true 123 | 124 | 125 | Console 126 | true 127 | true 128 | true 129 | 130 | 131 | 132 | 133 | 134 | 135 | Level3 136 | true 137 | true 138 | true 139 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 140 | true 141 | 142 | 143 | Console 144 | true 145 | true 146 | true 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | -------------------------------------------------------------------------------- /TRIE Overview.md: -------------------------------------------------------------------------------- 1 | # TRIE Overview 2 | 3 | There are a handful of different ways to represent something as seemingly simple as a set of 4 | words. For example, a hash or dictionary is one that we’re probably familiar with, as is as hash 5 | table. But there’s another structure that was created to solve the very problem of representing 6 | a set of words: a trie. The term “trie” comes from the word retrieval, and is usually pronounced 7 | “try”, to distinguish it from other “tree” structures. 8 | 9 | However, a trie is basically a tree data structure, but it just has a few rules to follow in terms 10 | of how it is created and used. 11 | 12 | ![alt text](https://github.com/HxnDev/Console-Based-Notepad-using-Trie-Trees/blob/main/temp/1.png?raw=true) 13 | 14 | A trie is a tree-like data structure whose nodes store the letters of an alphabet. By structuring 15 | the nodes in a particular way, words and strings can be retrieved from the structure by 16 | traversing down a branch path of the tree. 17 | 18 | Tries in the context of computer science are a relatively new thing. The first time that they were 19 | considered in computing was back in 1959, when a Frenchman named René de la Briandais 20 | suggested using them. According to Donald Knuth’s research in The Art of Computer 21 | Programming: 22 | 23 | Trie memory for computer searching was first recommended by René de la Briandais. He 24 | pointed out that we can save memory space at the expense of running time if we use a linked 25 | list for each node vector, since most of the entries in the vectors tend to be empty. 26 | 27 | The original idea behind using tries as a computing structure was that they could be a nice 28 | compromise between running time and memory. But we’ll come back to that in a bit. First, 29 | let’s take a step back and try and understand what exactly this structure looks like to start. 30 | 31 | ![alt text](https://github.com/HxnDev/Console-Based-Notepad-using-Trie-Trees/blob/main/temp/2.png?raw=true) 32 | 33 | We know that tries are often used to represent words in an alphabet. In the illustration shown 34 | here, we can start to get a sense of how exactly that representation works. 35 | 36 | Each trie has an empty root node, with links (or references) to other nodes — one for each 37 | possible alphabetic value. 38 | 39 | The shape and the structure of a trie is always a set of linked nodes, connecting back to an 40 | empty root node. An important thing to note is that the number of child nodes in a trie depends 41 | completely upon the total number of values possible. For example, if we are representing the 42 | English alphabet, then the total number of child nodes is directly connected to the total number 43 | of letters possible. In the English alphabet, there are 26 letters, so the total number of child 44 | nodes will be 26. 45 | 46 | Imagine, however, that we were creating a trie to hold words from the Khmer (Cambodian) 47 | alphabet, which is the longest known alphabet with 74 characters. In that case, the root node 48 | would contain 74 links to 74 other child nodes. 49 | 50 | 51 | The size of a trie is directly correlated to the size of all the possible values that the trie could 52 | represent. 53 | 54 | ![alt text](https://github.com/HxnDev/Console-Based-Notepad-using-Trie-Trees/blob/main/temp/3.png?raw=true) 55 | 56 | Okay, so a trie could be pretty small or big, depending on what it contains. But, so far, all we’ve 57 | talked about is the root node, which is empty. So where do the letters of different words live if 58 | the root node doesn’t house them all? 59 | 60 | The answer to that lies in the root node’s references to its children. Let’s take a closer look at 61 | what a single node in a trie looks like, and hopefully this will start to become clearer. 62 | 63 | In the example shown here, we have a trie that has an empty root node, which has references 64 | to children nodes. If we look at the cross-section of one of these child nodes, we’ll notice that 65 | a single node in a trie contains just two things: 66 | 67 | 1. A value, which might be null 68 | 2. An array of references to child nodes, all of which also might be null 69 | 70 | Each node in a trie, including the root node itself, has only these two aspects to it. When a trie 71 | representing the English language is created, it consists of a single root node, whose value is 72 | usually set to an empty string: "". 73 | 74 | That root node will also have an array that contains 26 references, all of which will point to 75 | null at first. As the trie grows, those pointers start to get filled up with references to other nodes 76 | nodes, which we’ll see an example of pretty soon. 77 | 78 | The way that those pointers or references are represented is particularly interesting. We know 79 | that each node contains an array of references/links to other nodes. What’s cool about this is 80 | that we can use the array’s indexes to find specific references to nodes. For example, our root 81 | node will hold an array of indexes 0 through 25, since there are 26 possible slots for the 26 82 | letters of the alphabet. Since the alphabet is in order, we know that the reference to the node 83 | that will contain the letter A will live at index 0. 84 | 85 | So, once we have a root node, where do we go from there? It’s time to try growing our trie! 86 | In the trie shown below, we’re representing the nursery rhyme that starts off with something 87 | like “Peter Piper picked a peck of pickled peppers”. 88 | 89 | ![alt text](https://github.com/HxnDev/Console-Based-Notepad-using-Trie-Trees/blob/main/temp/4.png?raw=true) 90 | 91 | Looking at our trie, we can see that we have an empty root node, as is typical for a trie structure. 92 | We also have six different words that we’re representing in this trie: Peter, piper, picked, peck, 93 | pickled, and peppers. 94 | 95 | To make this trie easier to look at, I’ve only drawn the references that actually have nodes in 96 | them; it’s important to remember that, even though they’re not illustrated here, every single 97 | node has 26 references to possible child nodes. 98 | 99 | Notice how there are six different “branches” to this trie, one for each word that’s being 100 | represented. We can also see that some words are sharing parent nodes. For example, all of the 101 | branches for the words Peter, peck, and peppers share the nodes for p and for e. Similarly, the 102 | path to the word picked and pickled share the nodes p, i, c, and k. 103 | 104 | 105 | So, what if we wanted to add the word pecked to this list of words represented by this trie? 106 | We’d need to do two things in order to make this happen: 107 | 108 | 1. First, we’d need to check that the word pecked doesn’t already exist in this trie. 109 | 2. Next, if we’ve traversed down the branch where this word ought to live and the words doesn’t 110 | exist yet, we’d insert a value into the node’s reference where the word should go. In this case, 111 | we’d insert e and d at the correct references. 112 | 113 | But how do we actually go about checking if the word exists? And how do we insert the letters 114 | into their correct places? This is easier to understand with a small trie as an example, so let’s 115 | look at a trie that is empty, and try inserting something into it. 116 | 117 | We know that we’ll have an empty root node, which will have a value of "", and an array with 118 | 26 references in it, all of which will be empty (pointing to null) to start. Let’s say that we want 119 | to insert the word "pie", and give it a value of 5. Another way to think about it is that we have 120 | a hash that looks like this: {“pie": 5}. 121 | 122 | ![alt text](https://github.com/HxnDev/Console-Based-Notepad-using-Trie-Trees/blob/main/temp/5.png?raw=true) 123 | 124 | We’ll work our way through the key, using each letter to build up our trie and add nodes as 125 | necessary. 126 | 127 | We’ll first look for the pointer for p, since the first letter in our key "pie" is p. Since this trie 128 | doesn’t have anything in just yet, the reference at p in our root node will be null. So, we’ll 129 | create a new node for p, and the root node now has an array with 25 empty slots, and 1 slot (at 130 | index 15) that contains a reference to a node. 131 | 132 | Now we have a node at index 15, holding the value for p. But, our string is "pie", so we’re not 133 | done yet. We’ll do the same thing for this node: check if there is a null pointer at the next letter 134 | of the key: i. Since we encounter another null link for the reference at i, we’ll create another 135 | new node. Finally, we’re at the last character of our key: the e in "pie". We create a new node 136 | for the array reference to e, and inside of this third node that we’ve created, we’ll set our value: 137 | 5. 138 | 139 | In the future, if we want to retrieve the value for the key "pie", we’ll traverse down from one 140 | array to another, using the indices to go from the nodes p, to i, to e; when we get to the node at 141 | the index for e, we’ll stop traversing, and retrieve the value from that node, which will be 5. 142 | 143 | ![alt text](https://github.com/HxnDev/Console-Based-Notepad-using-Trie-Trees/blob/main/temp/6.png?raw=true) 144 | 145 | Let’s actually take a look at what searching through our newly-built trie would look like! In 146 | the illustration shown here, if we search for the key "pie”, we traverse down each node’s array, 147 | and look to see if there is a value for the branch path: p-i-e. If it does have a value, we can 148 | simply return it. This is sometimes referred to as a search hit, since we were able to find a value 149 | for the key. But what if we search for something that doesn’t exist in our trie? What if we 150 | search for the word "pi”, which we haven’t added as a key with a value? Well, we’ll go from 151 | the root node to the node at index p, and then we’ll go from the node at p to the node at index 152 | i. When we get to this point, we’ll see if the node at the branch path p-i has a value. In this 153 | case, it doesn’t have a value; it’s pointing at null. So, we can be sure that the key "pi" doesn’t 154 | 155 | 156 | exist in our trie as a string with a value. This is often referred to as a search miss, since we 157 | could not find a value for the key. 158 | 159 | Finally, there’s one other action that we might want to do to our trie: delete things! How can 160 | we remove a key and its value from our trie structure? To illustrate this, I’ve added another 161 | word to our trie. We now have both the keys "pie" and "pies”, each with their own values. Let’s 162 | say we want to remove the key "pies" from our trie. 163 | 164 | ![alt text](https://github.com/HxnDev/Console-Based-Notepad-using-Trie-Trees/blob/main/temp/7.png?raw=true) 165 | 166 | In order to do this, we’d need to take two steps: 167 | 168 | 1. First, we need to find the node that contains the value for that key, and set its value to null. 169 | This means traversing down and finding the last letter of the word "pies”, and then resetting 170 | the value of the last node from 12 to null. 171 | 2. Second, we need to check the node’s references and see if all of its pointers to other nodes 172 | are also null. If all of them are empty, that means that there are no other words/branches below 173 | this one, and they can all be removed. However, if there are pointers for other nodes that do 174 | have values, we don’t want to delete the node that we’ve just set to null. 175 | 176 | This last check is particularly important in order to not remove longer strings when we remove 177 | substrings of a word. But other than that single check, there’s nothing more to it! 178 | 179 | - piper 180 | --someone who plays the bagpipe 181 | bagpiper 182 | musician 183 | player 184 | instrumentalist 185 | - pecked 186 | --(of a bird) strike or bite something with its beak. 187 | strike 188 | beak 189 | pick 190 | 191 | 192 | 193 | -------------------------------------------------------------------------------- /Code/MDList.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #include 6 | using namespace std; 7 | struct MDnode 8 | { 9 | MDnode* up, * down, * left, * right; 10 | char data; 11 | int xcoord, ycoord; 12 | }; 13 | class MDList 14 | { 15 | public: 16 | MDnode* head; 17 | MDnode* current; 18 | int returningx, returningy; 19 | public: 20 | MDList() //Constructor 21 | { 22 | head = NULL; 23 | current = NULL; 24 | } 25 | void Insert(char dataItem, int xx, int yy) //Inserts in to the list 26 | { 27 | 28 | MDnode* nodee = new MDnode; 29 | nodee->data = dataItem; 30 | nodee->xcoord = xx; 31 | nodee->ycoord = yy; 32 | if (head == NULL) 33 | { 34 | nodee->left = NULL; 35 | nodee->right = NULL; 36 | nodee->up = NULL; 37 | nodee->down = NULL; 38 | head = nodee; 39 | 40 | } 41 | else 42 | { 43 | MDnode* check = head; 44 | while (check != NULL and check->ycoord != yy) 45 | { 46 | check = check->down; 47 | } 48 | while (check != NULL and check->xcoord != xx) 49 | { 50 | check = check->right; 51 | } 52 | if (check != NULL) 53 | { 54 | check->data = dataItem; 55 | //charAt(check->xcoord, check->ycoord);////////////////// 56 | } 57 | else if (nodee->ycoord == head->ycoord) //inserts in the vertical direction (node->down) 58 | { 59 | MDnode* temp = head; 60 | while (temp->right != NULL) 61 | { 62 | temp = temp->right; 63 | } 64 | nodee->up = NULL; 65 | nodee->down = NULL; 66 | nodee->right = NULL; 67 | nodee->left = temp; 68 | temp->right = nodee; 69 | } 70 | else if (nodee->xcoord == head->xcoord)//inserts in the hoizontal direction (node->right) 71 | { 72 | MDnode* temp = head; 73 | while (temp->down != NULL) 74 | { 75 | temp = temp->down; 76 | } 77 | nodee->up = temp; 78 | nodee->down = NULL; 79 | nodee->right = NULL; 80 | nodee->left = NULL; 81 | temp->down = nodee; 82 | } 83 | 84 | else 85 | { 86 | MDnode* temp = head; 87 | while (temp->ycoord != yy) 88 | { 89 | temp = temp->down; 90 | } 91 | 92 | 93 | while (temp->right != NULL) 94 | { 95 | temp = temp->right; 96 | } 97 | 98 | nodee->down = NULL; 99 | nodee->right = NULL; 100 | nodee->left = temp; 101 | MDnode* temp1 = head; 102 | while (temp1->ycoord != yy - 1) 103 | { 104 | temp1 = temp1->down; 105 | } 106 | int val = 0; 107 | while (temp1!=NULL and temp1->xcoord != xx) 108 | { 109 | val = temp1->xcoord; 110 | temp1 = temp1->right; 111 | if (temp1 != NULL) 112 | { 113 | val = temp1->xcoord; 114 | } 115 | 116 | } 117 | if (val < xx) 118 | { 119 | nodee->up = NULL; 120 | temp->right = nodee; 121 | } 122 | else 123 | { 124 | nodee->up = temp1; 125 | temp->right = nodee; 126 | temp1->down = temp->right; 127 | } 128 | 129 | 130 | } 131 | 132 | } 133 | } 134 | int NULLCheck(int x, int y) 135 | { 136 | MDnode* nodee = new MDnode; 137 | nodee = head; 138 | 139 | for (int i = 1; i < y; i++) 140 | { 141 | nodee = nodee->down; 142 | } 143 | for (int i = 1; i <= x; i++) 144 | { 145 | if (nodee != NULL) 146 | { 147 | nodee = nodee->right; 148 | } 149 | } 150 | if (nodee == NULL) 151 | { 152 | return 1; 153 | } 154 | else return 0; 155 | } 156 | 157 | void Display() 158 | { 159 | //cout << endl; 160 | //cout << "displaying the list: " << endl; 161 | MDnode* nodee; 162 | MDnode* nodee1; 163 | nodee = head; 164 | while (nodee != NULL) 165 | { 166 | nodee1 = nodee; 167 | while (nodee1 != NULL) 168 | { 169 | cout << nodee1->data; 170 | nodee1 = nodee1->right; 171 | 172 | } 173 | cout << endl; 174 | nodee = nodee->down; 175 | } 176 | } 177 | void fileWriting() 178 | { 179 | string fname; 180 | ofstream f; 181 | //cin.ignore(); 182 | cout << "Please Enter the Name of the File = "; 183 | getline(cin, fname); 184 | fname += ".txt"; 185 | f.open(fname.c_str()); 186 | 187 | MDnode* nodee; 188 | MDnode* nodee1; 189 | nodee = head; 190 | while (nodee != NULL) 191 | { 192 | nodee1 = nodee; 193 | while (nodee1 != NULL) 194 | { 195 | f << nodee1->data; 196 | nodee1 = nodee1->right; 197 | 198 | } 199 | f << endl; 200 | nodee = nodee->down; 201 | } 202 | f.close(); 203 | 204 | } 205 | void remove(int xx, int yy) // for removing a character at specific coordinates (from the end) 206 | { 207 | MDnode* nodee = new MDnode; 208 | nodee = head; 209 | if (head != NULL) 210 | { 211 | for (int i = 1; i < yy; i++) 212 | { 213 | nodee = nodee->down; 214 | } 215 | for (int i = 1; i < xx; i++) 216 | { 217 | if (nodee->right != NULL) 218 | { 219 | nodee = nodee->right; 220 | } 221 | } 222 | //nodee = nodee->right; 223 | nodee->data; 224 | if (nodee != NULL and nodee->down == NULL and nodee->up == NULL and nodee->left != NULL and nodee->right == NULL) //if character has the same y coordinates as the head 225 | { 226 | MDnode* temp; 227 | MDnode* freeing; 228 | freeing = nodee; 229 | temp = nodee->left; 230 | //nodee->left = NULL; 231 | freeing->left = NULL; 232 | nodee = temp; 233 | nodee->right = NULL; 234 | delete freeing; 235 | } 236 | else if (nodee != NULL and nodee->down == NULL and nodee->left != NULL and nodee->right == NULL and nodee->up != NULL) //in case the y coordinate of the character is different from y coordinate of head 237 | { 238 | MDnode* temp; 239 | MDnode* temp1; 240 | MDnode* freeing; 241 | freeing = nodee; 242 | temp = nodee->left; 243 | temp1 = nodee->up; 244 | temp1->down = NULL; 245 | nodee->up = NULL; 246 | nodee->left = NULL; 247 | nodee = temp; 248 | nodee->right = NULL; 249 | delete freeing; 250 | } 251 | else if (nodee != NULL and nodee->down == NULL and nodee->left == NULL and nodee->right == NULL and nodee->up != NULL) //in case when user reaches the coordinate x=1 252 | { 253 | MDnode* temp = head; 254 | MDnode* temp1; 255 | MDnode* freeing; 256 | freeing = nodee; 257 | for (int i = 1; i < yy - 1; i++) 258 | { 259 | temp = temp->down; 260 | } 261 | temp1 = temp; 262 | while (temp1->right != NULL) 263 | { 264 | temp1 = temp1->right; 265 | } 266 | temp->down = NULL; 267 | freeing->up = NULL; 268 | nodee = temp; 269 | delete freeing; 270 | 271 | } 272 | else if (nodee != NULL and nodee->down == NULL and nodee->up == NULL and nodee->right != NULL and nodee->left != NULL) 273 | { 274 | MDnode* temp1; 275 | MDnode* temp2; 276 | temp1 = nodee->left; 277 | temp2 = nodee->right; 278 | MDnode* freeing; 279 | freeing = nodee; 280 | nodee->left->right = temp2; 281 | nodee->left->right->left = temp1; 282 | delete freeing; 283 | 284 | } 285 | } 286 | 287 | } 288 | 289 | int charAt(int xx, int yy) 290 | { 291 | int i = 0; 292 | MDnode* nodee = head; 293 | char char1; 294 | while (nodee->ycoord != yy) 295 | { 296 | nodee = nodee->down; 297 | } 298 | while (nodee != NULL and nodee->xcoord != xx) 299 | { 300 | nodee = nodee->right; 301 | } 302 | char1 = nodee->data; 303 | while ((nodee->data != ' ' and nodee->data != '.' and nodee->data != ',' and nodee->data != ';' and nodee->data != ':')) 304 | { 305 | if ((nodee->ycoord != 1 or nodee->left != NULL)) 306 | { 307 | if (nodee->left == NULL) 308 | { 309 | i++; 310 | nodee = nodee->up; 311 | while (nodee->right != NULL) 312 | { 313 | nodee = nodee->right; 314 | } 315 | } 316 | else 317 | 318 | { 319 | i++; 320 | nodee = nodee->left; 321 | } 322 | } 323 | else 324 | { 325 | i++; 326 | break; 327 | } 328 | } 329 | //cout << nodee->data; 330 | 331 | return i; 332 | } 333 | string stringAt(int xx, int yy) //after pressing special characters if a user wants to go back and display meaning of the word by making some changes in it 334 | { 335 | int i = 0; 336 | //cout << xx; 337 | string str; 338 | MDnode* nodee; 339 | nodee = head; 340 | if (head != NULL) 341 | { 342 | for (int i = 1; i < yy; i++) //checks where the character is present vertically 343 | { 344 | nodee = nodee->down; 345 | } 346 | for (int i = 1; i < xx; i++) //checks the exact location of the char horizontally 347 | { 348 | nodee = nodee->right; 349 | } 350 | while (nodee->left != NULL and nodee->left->data != ' ' and nodee->left->data != ';' and nodee->left->data != ':' and nodee->left->data != '.' and nodee->left->data != ',') //getting the size of the word 351 | { 352 | i++; 353 | 354 | if (nodee->xcoord != 1) 355 | { 356 | nodee = nodee->left; 357 | } 358 | if (nodee->xcoord == 1 and nodee->ycoord != 1) //when we're backspacing from the line below to the line above 359 | { 360 | nodee = nodee->up; 361 | while (nodee->right != NULL) 362 | { 363 | nodee = nodee->right; 364 | } 365 | i++; 366 | } 367 | } 368 | 369 | for (int j = 0; j < i; j++) //adding the character to form a string 370 | { 371 | 372 | str += nodee->data; 373 | if (nodee->right != NULL) 374 | { 375 | nodee = nodee->right; 376 | } 377 | else 378 | { 379 | MDnode* temp = head; 380 | while (temp->ycoord != nodee->ycoord + 1) 381 | { 382 | temp = temp->down; 383 | } 384 | nodee = temp; 385 | } 386 | } 387 | } 388 | return str; 389 | 390 | 391 | } 392 | bool SpecialCharCheck(int xx, int yy) //checks if the char at specific coordinate is ',' or '.' or ' ' or ';' or ':' 393 | { 394 | MDnode* nodee = head; 395 | while (nodee->ycoord != yy) 396 | { 397 | nodee = nodee->down; 398 | } 399 | while (nodee->xcoord != xx and nodee != NULL)//changes made 400 | { 401 | nodee = nodee->right; 402 | } 403 | if (nodee->data == ' ' or nodee->data == ',' or nodee->data == '.' or nodee->data == ';' or nodee->data == ':') 404 | { 405 | return true; 406 | } 407 | else 408 | return false; 409 | } 410 | void insertingAT(int xx, int yy) 411 | { 412 | 413 | } 414 | string savestring(int sx, int sy) 415 | { 416 | string s; 417 | MDnode* nodee = head; 418 | MDnode* temp; 419 | while (nodee->ycoord != sy) 420 | { 421 | nodee = nodee->down; 422 | } 423 | temp = nodee; 424 | while (nodee->right != NULL and nodee->right->xcoord != sx) 425 | { 426 | nodee = nodee->right; 427 | } 428 | while (temp != NULL) 429 | { 430 | while (nodee->right != NULL) 431 | { 432 | s += nodee->data; 433 | nodee = nodee->right; 434 | } 435 | s += nodee->data; 436 | temp = temp->down; 437 | if (temp != NULL) 438 | { 439 | nodee = temp; 440 | } 441 | } 442 | //nodee = nodee->left; 443 | //nodee = head; 444 | if (nodee != NULL and nodee->ycoord != sy) 445 | { 446 | MDnode* help; 447 | while (nodee->xcoord != 1) 448 | { 449 | help = nodee->left; 450 | remove(nodee->xcoord, nodee->ycoord); 451 | nodee = help; 452 | } 453 | int newx = nodee->xcoord, newy = nodee->ycoord; 454 | nodee = nodee->up; 455 | 456 | remove(newx, newy); 457 | while (nodee->right != NULL) 458 | { 459 | nodee = nodee->right; 460 | } 461 | } 462 | else 463 | { 464 | MDnode* neww; 465 | neww = nodee; 466 | while (nodee != NULL and nodee->xcoord != sx - 2) 467 | { 468 | neww = neww->left; 469 | remove(nodee->xcoord, nodee->ycoord); 470 | nodee = neww; 471 | } 472 | //if (nodee != NULL) 473 | //{ 474 | // remove(nodee->xcoord, nodee->ycoord); 475 | //} 476 | } 477 | //fileWriting(); 478 | 479 | return s; 480 | 481 | //cout << s; 482 | } 483 | void MemoryDeallocation() 484 | { 485 | MDnode* nodee = new MDnode; 486 | nodee = head; 487 | while (nodee->down != NULL) 488 | { 489 | nodee = nodee->down; 490 | } 491 | 492 | while (nodee->up != NULL) 493 | { 494 | while (nodee != NULL and nodee->right != NULL) 495 | { 496 | nodee = nodee->right; 497 | } 498 | while (nodee->left != NULL) 499 | { 500 | if (nodee != NULL and nodee->down == NULL and nodee->up == NULL and nodee->left != NULL and nodee->right == NULL) //if character has the same y coordinates as the head 501 | { 502 | MDnode* temp; 503 | MDnode* freeing; 504 | freeing = nodee; 505 | temp = nodee->left; 506 | //nodee->left = NULL; 507 | freeing->left = NULL; 508 | nodee = temp; 509 | nodee->right = NULL; 510 | delete freeing; 511 | } 512 | else if (nodee != NULL and nodee->down == NULL and nodee->left != NULL and nodee->right == NULL and nodee->up != NULL) //in case the y coordinate of the character is different from y coordinate of head 513 | { 514 | MDnode* temp; 515 | MDnode* temp1; 516 | MDnode* freeing; 517 | freeing = nodee; 518 | temp = nodee->left; 519 | temp1 = nodee->up; 520 | temp1->down = NULL; 521 | nodee->up = NULL; 522 | nodee->left = NULL; 523 | nodee = temp; 524 | nodee->right = NULL; 525 | delete freeing; 526 | } 527 | else if (nodee != NULL and nodee->down == NULL and nodee->left == NULL and nodee->right == NULL and nodee->up != NULL) //in case when user reaches the coordinate x=1 528 | { 529 | MDnode* temp; 530 | MDnode* temp1; 531 | MDnode* freeing; 532 | freeing = nodee; 533 | temp = nodee->up; 534 | temp->down = NULL; 535 | freeing->left = NULL; 536 | freeing->up = NULL; 537 | freeing->down = NULL; 538 | freeing->right = NULL; 539 | nodee = nodee->left; 540 | nodee->right = NULL; 541 | delete freeing; 542 | } 543 | else if (nodee != NULL and nodee->down == NULL and nodee->up == NULL and nodee->right != NULL and nodee->left != NULL) 544 | { 545 | MDnode* temp1; 546 | MDnode* temp2; 547 | temp1 = nodee->left; 548 | temp2 = nodee->right; 549 | MDnode* freeing; 550 | freeing = nodee; 551 | nodee->left->right = temp2; 552 | nodee->left->right->left = temp1; 553 | delete freeing; 554 | 555 | } 556 | //nodee = nodee->left; 557 | } 558 | MDnode* temp; 559 | MDnode* temp1; 560 | MDnode* freeing; 561 | freeing = nodee; 562 | temp = nodee->up; 563 | temp->down = NULL; 564 | freeing->left = NULL; 565 | freeing->up = NULL; 566 | freeing->down = NULL; 567 | freeing->right = NULL; 568 | //nodee = nodee->left; 569 | //nodee->right = NULL; 570 | delete freeing; 571 | 572 | nodee = temp; 573 | } 574 | 575 | if (nodee->up == NULL) 576 | { 577 | while (nodee != NULL and nodee->right != NULL) 578 | { 579 | nodee = nodee->right; 580 | } 581 | while (nodee->left != NULL) 582 | { 583 | if (nodee != NULL and nodee->down == NULL and nodee->up == NULL and nodee->left != NULL and nodee->right == NULL) //if character has the same y coordinates as the head 584 | { 585 | MDnode* temp; 586 | MDnode* freeing; 587 | freeing = nodee; 588 | temp = nodee->left; 589 | //nodee->left = NULL; 590 | freeing->left = NULL; 591 | nodee = temp; 592 | nodee->right = NULL; 593 | delete freeing; 594 | } 595 | else if (nodee != NULL and nodee->down == NULL and nodee->left != NULL and nodee->right == NULL and nodee->up != NULL) //in case the y coordinate of the character is different from y coordinate of head 596 | { 597 | MDnode* temp; 598 | MDnode* temp1; 599 | MDnode* freeing; 600 | freeing = nodee; 601 | temp = nodee->left; 602 | temp1 = nodee->up; 603 | temp1->down = NULL; 604 | nodee->up = NULL; 605 | nodee->left = NULL; 606 | nodee = temp; 607 | nodee->right = NULL; 608 | delete freeing; 609 | } 610 | else if (nodee != NULL and nodee->down == NULL and nodee->left == NULL and nodee->right == NULL and nodee->up != NULL) //in case when user reaches the coordinate x=1 611 | { 612 | MDnode* temp; 613 | MDnode* temp1; 614 | MDnode* freeing; 615 | freeing = nodee; 616 | temp = nodee->up; 617 | temp->down = NULL; 618 | freeing->left = NULL; 619 | freeing->up = NULL; 620 | freeing->down = NULL; 621 | freeing->right = NULL; 622 | nodee = nodee->left; 623 | nodee->right = NULL; 624 | delete freeing; 625 | } 626 | else if (nodee != NULL and nodee->down == NULL and nodee->up == NULL and nodee->right != NULL and nodee->left != NULL) 627 | { 628 | MDnode* temp1; 629 | MDnode* temp2; 630 | temp1 = nodee->left; 631 | temp2 = nodee->right; 632 | MDnode* freeing; 633 | freeing = nodee; 634 | nodee->left->right = temp2; 635 | nodee->left->right->left = temp1; 636 | delete freeing; 637 | 638 | } 639 | //nodee = nodee->left; 640 | } 641 | MDnode* temp; 642 | MDnode* temp1; 643 | MDnode* freeing; 644 | freeing = nodee; 645 | freeing->left = NULL; 646 | freeing->up = NULL; 647 | freeing->down = NULL; 648 | freeing->right = NULL; 649 | //nodee = nodee->left; 650 | //nodee->right = NULL; 651 | head = NULL; 652 | delete freeing; 653 | } 654 | 655 | 656 | } 657 | void afterdeletion() 658 | { 659 | string fname; 660 | ofstream f; 661 | /*cout << "please enter the name of the file"; 662 | getline(cin, fname); 663 | fname += ".txt";*/ 664 | fname = "imdone1.txt"; 665 | f.open(fname.c_str()); 666 | 667 | MDnode* nodee; 668 | MDnode* nodee1; 669 | nodee = head; 670 | while (nodee != NULL) 671 | { 672 | nodee1 = nodee; 673 | while (nodee1 != NULL) 674 | { 675 | f << nodee1->data; 676 | nodee1 = nodee1->right; 677 | 678 | } 679 | f << endl; 680 | nodee = nodee->down; 681 | } 682 | f.close(); 683 | } 684 | void gotoxy(int x, int y) //Sets coordinates 685 | { 686 | 687 | ///COORD = Structure of Coordinates 688 | COORD c = { x, y }; 689 | ///STD_OUTPUT_HANDLE = Output mode 690 | SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), c); //Sets co-ordinates 691 | 692 | } 693 | void loadingFile(int start) 694 | { 695 | string line; 696 | string fname; 697 | fstream f; 698 | int len = 0; 699 | int x = 1, y = 1; 700 | cin.ignore(); 701 | loop: 702 | cout << "Please Enter the Name of the File that You Want to Read from = "; 703 | getline(cin, fname); 704 | fname += ".txt"; 705 | system("cls"); 706 | f.open(fname.c_str()); 707 | if (f.is_open()) 708 | { 709 | while (getline(f, line)) 710 | { 711 | len = line.length(); 712 | } 713 | f.close(); 714 | } 715 | else 716 | { 717 | cout << "Invalid Name Entered!!"< 6 | #include 7 | #include 8 | using namespace std; 9 | int c, r; //Stores the coordinates of the console window 10 | int countLines = 0; 11 | int shiftcheck = 0; 12 | int nextline = 0; 13 | int movecheck = 0; 14 | char safechar; 15 | int finalcheck = 0, point = 0; 16 | int bsp = 0; //backspace (using a check fr occurance of backspace) 17 | int movekeycheck = 0, currentx = 0, currenty = 0; 18 | int exx = 0, exy = 0; 19 | int finallyover = 0; 20 | MDList mdlist; 21 | 22 | 23 | void gotoxy(int x, int y) //Sets coordinates 24 | { 25 | 26 | ///COORD = Structure of Coordinates 27 | COORD c = { x, y }; 28 | ///STD_OUTPUT_HANDLE = Output mode 29 | SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), c); //Sets co-ordinates 30 | 31 | } 32 | 33 | 34 | class Notepad { 35 | private: 36 | float x = 1, y = 1; 37 | int start; 38 | string s, meaning; 39 | TRIE trie; 40 | bool flag = false; 41 | bool exist = true; 42 | 43 | public: 44 | 45 | Notepad() 46 | { 47 | x = 1; 48 | y = 1; 49 | s = ""; 50 | start = 0; 51 | meaning = ""; 52 | } 53 | 54 | 55 | void getConsoleSize() //This function will return the console size of each laptop 56 | { 57 | CONSOLE_SCREEN_BUFFER_INFO csbi; 58 | GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); 59 | c = csbi.srWindow.Right - csbi.srWindow.Left + 1; //stores the number of columns 60 | r = csbi.srWindow.Bottom - csbi.srWindow.Top + 1; //stores the number of rows 61 | start = c * (0.70); 62 | } 63 | 64 | 65 | void SplitScreen() //Splitting screen into two "0-169" and "170-230" 66 | { 67 | x = start; 68 | y = countLines; 69 | gotoxy(x, y); 70 | } 71 | 72 | 73 | void Backspace() //Checks if backspace is pressed 74 | { 75 | x--; 76 | gotoxy(x, y); 77 | cout << " "; 78 | if (x == 1 and y != 1) 79 | { 80 | x = start - 10; 81 | y--; 82 | } 83 | else 84 | { 85 | x--; 86 | } 87 | gotoxy(x, y); 88 | 89 | 90 | } 91 | 92 | 93 | 94 | 95 | 96 | 97 | void NotFound() //Displays error message in splitted screen if word is not found 98 | { 99 | int temp = x; 100 | int temp2 = y; 101 | SplitScreen(); 102 | cout << "Entered word not found" << endl; 103 | x = temp+1; 104 | y = temp2; 105 | gotoxy(x, y); 106 | } 107 | 108 | 109 | void DisplayMeaning() //Displays Meaning on Console 110 | { 111 | int count = 0; 112 | int len = 0; 113 | int temp = x; 114 | int temp2 = y; 115 | meaning = trie.FindMeaning(s); //Finds meaning of the string before space 116 | SplitScreen(); 117 | len = meaning.size(); 118 | for (int i = 0; i < len; i++) 119 | { 120 | if (count >= (c - start - 2)) 121 | { 122 | y++; 123 | countLines++; 124 | x = start; 125 | gotoxy(x, y); 126 | count = 0; 127 | } 128 | count++; 129 | cout << meaning[i]; 130 | x++; 131 | } 132 | x = temp ; 133 | y = temp2; 134 | countLines++; 135 | gotoxy(x, y); 136 | } 137 | 138 | 139 | void DisplaySynonyms() //Displays synonyms of the word 140 | { 141 | TrieNode* obj = trie.FindNode(s); 142 | 143 | int temp1 = x; 144 | int temp2 = y; 145 | 146 | int size = obj->synonyms.getSize(); //size of synonym list 147 | 148 | for(int i=0; isynonyms[i]; 151 | SplitScreen(); //Moving cursor to other side of splitted screen 152 | countLines++; 153 | cout << temp << endl; 154 | 155 | temp = ""; 156 | } 157 | x = temp1 + 1; 158 | y = temp2; 159 | gotoxy(x, y); //Moves cursor back to original location 160 | } 161 | 162 | 163 | void Interface() //Displays a Welcome Screen 164 | { 165 | Sleep(1000); 166 | system("color 30"); 167 | fstream file("Welcome1.txt", ios::in); //"Welcome" 168 | while (!file.eof()) 169 | { 170 | string title; 171 | getline(file, title); 172 | cout << title << endl; 173 | } 174 | file.close(); 175 | cout << endl; 176 | Sleep(1000); 177 | cout << endl; 178 | 179 | 180 | file.open("Welcome2.txt", ios::in); //"to" 181 | while (!file.eof()) 182 | { 183 | string title; 184 | getline(file, title); 185 | cout << "\t \t" << title << endl; 186 | } 187 | file.close(); 188 | cout << endl; 189 | Sleep(1000); 190 | cout << endl; 191 | 192 | 193 | file.open("Welcome3.txt", ios::in); //"DS" 194 | while (!file.eof()) 195 | { 196 | string title; 197 | getline(file, title); 198 | cout << "\t \t \t" << title << endl; 199 | } 200 | file.close(); 201 | cout << endl; 202 | Sleep(1000); 203 | 204 | 205 | file.open("Welcome4.txt", ios::in); //"Project" 206 | while (!file.eof()) 207 | { 208 | string title; 209 | getline(file, title); 210 | cout << "\t \t \t \t \t \t" << title << endl; 211 | } 212 | file.close(); 213 | cout << endl; 214 | Sleep(3000); 215 | system("cls"); 216 | 217 | system("color 47"); 218 | file.open("MenuTitle.txt", ios::in); //"Notepad" 219 | while (!file.eof()) 220 | { 221 | string temp; 222 | getline(file, temp); 223 | cout << temp << endl; 224 | } 225 | file.close(); 226 | cout << endl; 227 | Sleep(1000); 228 | 229 | 230 | file.open("Credits1.txt", ios::in); //"by" 231 | while (!file.eof()) 232 | { 233 | string temp; 234 | getline(file, temp); 235 | cout << temp << endl; 236 | } 237 | file.close(); 238 | cout << endl; 239 | Sleep(1000); 240 | 241 | 242 | file.open("Credits2.txt", ios::in); //"Azka & Hassan" 243 | while (!file.eof()) 244 | { 245 | string temp; 246 | getline(file, temp); 247 | cout << "\t" << temp << endl; 248 | } 249 | file.close(); 250 | Sleep(3000); 251 | 252 | } 253 | 254 | void Saved() //"Changes have been saved" 255 | { 256 | system("cls"); 257 | system("color 4e"); 258 | fstream file("saved.txt", ios::in); //"Changes saved. The program will end in... " 259 | while (!file.eof()) 260 | { 261 | string title; 262 | getline(file, title); 263 | cout << title << endl; 264 | } 265 | file.close(); 266 | Sleep(1000); 267 | 268 | file.open("end1.txt", ios::in); //"3.." 269 | while (!file.eof()) 270 | { 271 | string title; 272 | getline(file, title); 273 | cout << title << endl; 274 | } 275 | file.close(); 276 | Sleep(1000); 277 | 278 | file.open("end2.txt", ios::in); //"2.." 279 | while (!file.eof()) 280 | { 281 | string title; 282 | getline(file, title); 283 | cout << "\t" << title << endl; 284 | } 285 | file.close(); 286 | Sleep(1000); 287 | 288 | file.open("end3.txt", ios::in); //"1.." 289 | while (!file.eof()) 290 | { 291 | string title; 292 | getline(file, title); 293 | cout << "\t\t" << title << endl; 294 | } 295 | file.close(); 296 | Sleep(1000); 297 | 298 | system("cls"); 299 | system("color 47"); 300 | file.open("bye.txt", ios::in); //"Bye" 301 | while (!file.eof()) 302 | { 303 | string title; 304 | getline(file, title); 305 | cout << "\t\t\t" << title << endl; 306 | } 307 | file.close(); 308 | cout << endl << endl; 309 | Sleep(1000); 310 | exit(0); 311 | 312 | } 313 | 314 | void NotSaved() //"Changes were not saved" 315 | { 316 | system("cls"); 317 | system("color 4e"); 318 | fstream file("notsaved.txt", ios::in); //"Changes not saved. The program will end in... " 319 | while (!file.eof()) 320 | { 321 | string title; 322 | getline(file, title); 323 | cout << title << endl; 324 | } 325 | file.close(); 326 | Sleep(1000); 327 | 328 | file.open("end1.txt", ios::in); //"3.." 329 | while (!file.eof()) 330 | { 331 | string title; 332 | getline(file, title); 333 | cout << title << endl; 334 | } 335 | file.close(); 336 | Sleep(1000); 337 | 338 | file.open("end2.txt", ios::in); //"2.." 339 | while (!file.eof()) 340 | { 341 | string title; 342 | getline(file, title); 343 | cout << "\t" << title << endl; 344 | } 345 | file.close(); 346 | Sleep(1000); 347 | 348 | file.open("end3.txt", ios::in); //"1.." 349 | while (!file.eof()) 350 | { 351 | string title; 352 | getline(file, title); 353 | cout << "\t\t" << title << endl; 354 | } 355 | file.close(); 356 | Sleep(1000); 357 | 358 | system("cls"); 359 | system("color 47"); 360 | file.open("bye.txt", ios::in); //"Bye" 361 | while (!file.eof()) 362 | { 363 | string title; 364 | getline(file, title); 365 | cout << "\t\t\t" << title << endl; 366 | } 367 | file.close(); 368 | cout << endl << endl; 369 | Sleep(1000); 370 | exit(0); 371 | } 372 | 373 | void Invalid() //"Invalid option selected" 374 | { 375 | system("cls"); 376 | system("color 49"); 377 | fstream file("invalid.txt", ios::in); //"Invalid Key pressed " 378 | while (!file.eof()) 379 | { 380 | string title; 381 | getline(file, title); 382 | cout << title << endl; 383 | } 384 | file.close(); 385 | Sleep(1000); 386 | 387 | exit(0); 388 | } 389 | 390 | 391 | 392 | void DisplayMenu() //Displays the menu 393 | { 394 | system("cls"); 395 | system("color 5e"); //Blue + Yellow 396 | fstream file("D1.txt", ios::in); //"Following are the list of options: " 397 | while (!file.eof()) 398 | { 399 | string title; 400 | getline(file, title); 401 | cout << title << endl; 402 | } 403 | file.close(); 404 | cout << endl; 405 | 406 | Sleep(1000); 407 | 408 | 409 | file.open("D2.txt", ios::in); //"1: New File" 410 | while (!file.eof()) 411 | { 412 | string title; 413 | getline(file, title); 414 | cout << "\t" << title << endl; 415 | } 416 | file.close(); 417 | cout << endl; 418 | Sleep(1000); 419 | 420 | 421 | file.open("D3.txt", ios::in); //"2: Existing File" 422 | while (!file.eof()) 423 | { 424 | string title; 425 | getline(file, title); 426 | cout << "\t" << title << endl; 427 | } 428 | file.close(); 429 | cout << endl; 430 | Sleep(1000); 431 | cout << endl << endl; 432 | 433 | file.open("D4.txt", ios::in); //"Select your option" 434 | while (!file.eof()) 435 | { 436 | string title; 437 | getline(file, title); 438 | cout << "\t \t" << title << endl; 439 | } 440 | file.close(); 441 | cout << endl; 442 | 443 | int op; 444 | cin >> op; 445 | 446 | if (op == 1) 447 | { 448 | cout << "New File Selected\n \n"; 449 | system("cls"); 450 | x = 1, y = 1; 451 | gotoxy(x, y); 452 | } 453 | else if (op == 2) 454 | { 455 | cout << "Existing file selected\n\n"; 456 | mdlist.loadingFile(start); 457 | x = mdlist.returningx, y = mdlist.returningy; 458 | gotoxy(x, y); 459 | } 460 | else 461 | Invalid(); 462 | } 463 | 464 | void ExitMenu() 465 | { 466 | system("cls"); 467 | system("color 27"); 468 | fstream file("exitmenu.txt", ios::in); //"Do you want to save the changes?" 469 | while (!file.eof()) 470 | { 471 | string title; 472 | getline(file, title); 473 | cout << title << endl; 474 | } 475 | file.close(); 476 | cout << endl; 477 | 478 | Sleep(1000); 479 | cout << endl; 480 | 481 | file.open("Exit1.txt", ios::in); //"1:Yes 2: No" 482 | while (!file.eof()) 483 | { 484 | string title; 485 | getline(file, title); 486 | cout << "\t" << title << endl; 487 | } 488 | file.close(); 489 | cout << endl << endl << endl; 490 | 491 | int op; 492 | cin >> op; 493 | if (op == 1) 494 | { 495 | cin.ignore(); 496 | mdlist.fileWriting(); 497 | mdlist.MemoryDeallocation(); 498 | Saved(); 499 | } 500 | else if (op == 2) 501 | { 502 | mdlist.MemoryDeallocation(); 503 | NotSaved(); 504 | } 505 | else 506 | { 507 | Invalid(); 508 | } 509 | Sleep(1000); 510 | } 511 | 512 | 513 | 514 | void ExitScreen() 515 | { 516 | system("cls"); 517 | system("color 70"); 518 | fstream file("Exit.txt", ios::in); //"Do you really want to exit?" 519 | while (!file.eof()) 520 | { 521 | string title; 522 | getline(file, title); 523 | cout << "\t" << title << endl; 524 | } 525 | file.close(); 526 | Sleep(1000); 527 | 528 | file.open("sademoji.txt", ios::in); //":(" 529 | while (!file.eof()) 530 | { 531 | string title; 532 | getline(file, title); 533 | cout << "\t\t" << title << endl; 534 | } 535 | file.close(); 536 | cout << endl; 537 | Sleep(1000); 538 | cout << endl; 539 | 540 | 541 | file.open("Exit1.txt", ios::in); //Choice 542 | while (!file.eof()) 543 | { 544 | string title; 545 | getline(file, title); 546 | cout << "\t" << title << endl; 547 | } 548 | file.close(); 549 | cout << endl; 550 | cout << endl; 551 | 552 | int op; 553 | cin >> op; 554 | if (op == 1) 555 | { 556 | ExitMenu(); 557 | } 558 | else if (op == 2) 559 | { 560 | cout << "Function is not exitted" << endl; 561 | } 562 | else 563 | { 564 | Invalid(); 565 | } 566 | } 567 | 568 | 569 | void Escape() //Checks if Esc Key is pressed 570 | { 571 | ExitScreen(); 572 | exit(0); 573 | } 574 | 575 | 576 | 577 | void RunAll() 578 | { 579 | Interface(); 580 | 581 | system("cls"); //Clears Screen 582 | 583 | getConsoleSize(); 584 | 585 | //--------Tree objects-----------------------// 586 | trie.CreateDictionary("dictionary.txt"); 587 | 588 | 589 | 590 | 591 | ///Handle is sort of datatype which tells the device we are using 592 | ///STD_INPUT_HANDLE = Input mode 593 | 594 | HANDLE rhnd = GetStdHandle(STD_INPUT_HANDLE); // Handle to read console 595 | 596 | ///Events = any sort of operation happening (e.g key press / mouse click) 597 | ///DWORD = long unsigned integer (Alternative keyword) 598 | DWORD Events = 0; // Event count 599 | DWORD EventsRead = 0; // Events read from console 600 | 601 | bool Running = true; //Tells if console is running or not 602 | 603 | 604 | gotoxy(x, y); 605 | 606 | //Main loop of program 607 | 608 | while (Running) 609 | { 610 | if (finallyover == 0) 611 | { 612 | DisplayMenu(); 613 | finallyover++; 614 | } 615 | 616 | 617 | // gets the systems current "event" count 618 | GetNumberOfConsoleInputEvents(rhnd, &Events); 619 | 620 | if (Events != 0) { // Tells that an event occured 621 | 622 | // create event buffer(array) the size of how many Events 623 | INPUT_RECORD eventBuffer[200]; 624 | 625 | // Fills the event buffer with the events and saves count in EventsRead 626 | ReadConsoleInput(rhnd, eventBuffer, Events, &EventsRead); 627 | 628 | // Loop through the event buffer using the saved count 629 | for (DWORD i = 0; i < EventsRead; ++i) { 630 | 631 | // check if event[i] is a key event && if so is a press not a release 632 | if (eventBuffer[i].EventType == KEY_EVENT && eventBuffer[i].Event.KeyEvent.bKeyDown) 633 | { 634 | // check if the key press was an arrow key 635 | switch (eventBuffer[i].Event.KeyEvent.wVirtualKeyCode) 636 | { 637 | 638 | case VK_UP: //up 639 | if (movekeycheck == 0) 640 | { 641 | movekeycheck++; 642 | currentx = x; 643 | currenty = y; 644 | } 645 | y--; 646 | gotoxy(x, y); 647 | movecheck++; 648 | if (mdlist.NULLCheck(x, y) == 1) 649 | { 650 | movekeycheck = 0; 651 | } 652 | break; 653 | 654 | case VK_DOWN: //down 655 | if (movekeycheck == 0) 656 | { 657 | movekeycheck++; 658 | currentx = x; 659 | currenty = y; 660 | } 661 | y++; 662 | gotoxy(x, y); 663 | movecheck++; 664 | if (mdlist.NULLCheck(x, y) == 1) 665 | { 666 | movekeycheck = 0; 667 | } 668 | break; 669 | 670 | case VK_RIGHT: //right 671 | if (movekeycheck == 0) 672 | { 673 | movekeycheck++; 674 | currentx = x; 675 | currenty = y; 676 | } 677 | x++; 678 | gotoxy(x, y); 679 | movecheck++; 680 | if (mdlist.NULLCheck(x, y) == 1) 681 | { 682 | movekeycheck = 0; 683 | } 684 | break; 685 | 686 | case VK_LEFT: //left 687 | if (movekeycheck == 0) 688 | { 689 | movekeycheck++; 690 | currentx = x; 691 | currenty = y; 692 | } 693 | x--; 694 | gotoxy(x, y); 695 | movecheck++; 696 | if (mdlist.NULLCheck(x, y) == 1) 697 | { 698 | movekeycheck = 0; 699 | } 700 | break; 701 | 702 | case VK_SHIFT: 703 | shiftcheck++; 704 | break; 705 | default: //Keypress was not arrow key 706 | //movekeycheck = 0; 707 | char c = eventBuffer->Event.KeyEvent.uChar.AsciiChar; //identifies which ascii character is pressed and stores its value in "c" 708 | if (c == VK_SPACE or c == '.' or c == ',' or c == ';' or c == ':') 709 | { 710 | movecheck = 0; 711 | } 712 | if (c == 8 and x == 1 and y == 1) 713 | { 714 | exit(1); 715 | } 716 | /* if (c == '9') 717 | { 718 | mdlist.fileWriting(); 719 | mdlist.MemoryDeallocation(); 720 | mdlist.afterdeletion(); 721 | }*/ 722 | if (c != 8) 723 | { 724 | mdlist.Insert(c, x, y); 725 | } 726 | if (c != ' ') 727 | { 728 | cout << c; //Displays the character pressed on Console 729 | } 730 | if (c == ' ' and bsp != 0) 731 | { 732 | cout << c; 733 | bsp = 0; 734 | } 735 | if (x + 10 == start and c!=8) 736 | { 737 | y++; 738 | x = 1; 739 | gotoxy(x, y); 740 | nextline++; 741 | } 742 | 743 | if (c == VK_SPACE or c == '.' or c == ',' or c == ';' or c == ':') //Checking if 'SpaceBar' or ',' or '.' or ';' or ':' is pressed 744 | { 745 | if (trie.FindWord(s)) //Checks if word is found 746 | { 747 | DisplayMeaning(); 748 | DisplaySynonyms(); 749 | s = ""; 750 | flag = true; 751 | } 752 | else 753 | { 754 | NotFound(); //Displays not found message 755 | s = ""; 756 | flag = true; 757 | } 758 | 759 | 760 | } 761 | if (!flag and c!=8) 762 | { 763 | s += c; //Adding that character to a string 764 | 765 | } 766 | else 767 | flag = false; 768 | if (nextline == 0 and c!=' ' and c != '.' and c != ',' and c != ';' and c != ':' )///////////////// 769 | { 770 | x++; 771 | } 772 | 773 | 774 | if (nextline != 0 and (c == ' ' or c == '.' or c == ',' or c == ';' or c == ':')) 775 | { 776 | x = 1; 777 | gotoxy(1, y); 778 | } 779 | else 780 | { 781 | gotoxy(x, y); //Jumps to these coordinates 782 | } 783 | 784 | nextline = 0; 785 | if (c == 27) //Checks if "Esc" key is pressed 786 | { 787 | Escape(); 788 | } 789 | int x1, y1; 790 | if (c == 8 and movekeycheck == 1) 791 | { 792 | string saved; 793 | //if (finalcheck % 2 == 0) 794 | { 795 | //x = x - finalcheck; 796 | } 797 | if (point != 0) 798 | { 799 | x = finalcheck - 1; 800 | } 801 | point += 1; 802 | saved = mdlist.savestring(x, y); 803 | int backx = 0, backy = 0; 804 | backx = x, backy = y; 805 | x = currentx, y = currenty; 806 | gotoxy(x, y); 807 | for (int j = y; j >= backy; j--) 808 | { 809 | if (j != backy) 810 | { 811 | for (int i = x; i > 0; i--) 812 | { 813 | cout << " "; 814 | gotoxy(i, j); 815 | //gotoxy(i, j); 816 | //Backspace(); 817 | 818 | } 819 | if (i == 0) 820 | { 821 | x = start - 10; 822 | } 823 | } 824 | if (j == backy) 825 | { 826 | for (int i = x; i >= backx - 1; i--) 827 | { 828 | cout << " "; 829 | gotoxy(i, j); 830 | //gotoxy(i, j); 831 | //Backspace(); 832 | x1 = i, y1 = j; 833 | } 834 | } 835 | } 836 | cout << " "; 837 | x1 = x1 - 1; 838 | gotoxy(x1 , y1); 839 | // mdlist.fileWriting(); 840 | mdlist.remove(x1, y1); 841 | //x1++; 842 | int slen = saved.length(); 843 | // mdlist.fileWriting(); 844 | for (int a = 0; a < slen; a++) 845 | { 846 | mdlist.Insert(saved[a], x1, y1); 847 | x1 = x1 + 1; 848 | } 849 | //mdlist.fileWriting(); 850 | cout << saved; 851 | gotoxy(backx - 2, backy); 852 | x = backx, y = backy; 853 | finalcheck = x; 854 | // mdlist.fileWriting(); 855 | } 856 | else if (c == 8 and movekeycheck == 0) //Checks if "Backspace" key is pressed 857 | { 858 | bsp++; 859 | if (safechar != ' ' and safechar != '.' and safechar != ',' and safechar != ';' and safechar != ':') 860 | { 861 | int len = 0; 862 | len = s.length(); 863 | if (len != 0) 864 | { 865 | s.erase(len - 1); //erases the last character from sring that the user wants to remove 866 | } 867 | } 868 | Backspace(); 869 | mdlist.SpecialCharCheck(x, y); 870 | if (safechar == ' ' or safechar == '.' or safechar == ',' or safechar == ';' or safechar == ':' or mdlist.SpecialCharCheck(x, y) == true) 871 | { 872 | s = mdlist.stringAt(x, y); 873 | } 874 | mdlist.remove(x, y); 875 | } 876 | /*if (movecheck != 0) 877 | { 878 | int a = 0; 879 | a = mdlist.charAt(x - 1, y); 880 | int len = 0; 881 | len = s.length(); 882 | if (len != 0) 883 | { 884 | s.erase(len - 1); //erases the last character from sring that the user wants to remove 885 | } 886 | s[a-1] = c; 887 | movecheck = 0; 888 | }*/ 889 | safechar = c; 890 | //movekeycheck = 0; 891 | } 892 | } 893 | 894 | } // end of EventsRead loop 895 | 896 | } 897 | 898 | } // end of program loop 899 | } 900 | }; --------------------------------------------------------------------------------