-
Notifications
You must be signed in to change notification settings - Fork 1
/
frontend.py
825 lines (741 loc) · 27.5 KB
/
frontend.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
import os
import shutil
import string
import time
import apiCalls
import json
import requests
import easygui
# Base frontend functionality
def clearConsole():
os.system('cls' if os.name == 'nt' else 'clear')
def getConfig(line):
# Line 2 is Primary color, 4 is Secondary color, 6 is pro mode
with open('config.txt', 'r') as file:
lines = file.readlines()
# Reads the line looked at (non-array indexing)
return lines[(line - 1)]
def setConfig(line, newContent):
with open('config.txt', 'r') as file:
lines = file.readlines()
lines[(line-1)] = str(newContent) + '\n'
with open('config.txt', 'w') as file:
file.writelines(lines)
def optionColors():
for i in range(0,255):
print(f"\033[38;5;{str(i)}m{i}\033[0m", end = "\n" if i == 254 else ", ")
def printColor(text, color, tail = "\n"):
color = str(color)
print(f"\033[38;5;{color}m{text}\033[0m", end = tail)
def lineBreak(columns, color):
line = '-'
for i in range(1,columns):
line += '-'
printColor(line, color, "")
def translation(response_string):
text = ""
inside_quotes = False
new_line_check = False
for num_str in response_string:
num = num_str
if num == 34: # ASCII code for double quotation mark (")
inside_quotes = not inside_quotes
elif inside_quotes:
text += chr(num)
new_line_check = True
elif new_line_check:
text += "\n"
new_line_check = False
return text
def input_pre_filled(prompt, prefill):
#Pass a prompt as if operating a normal input() statement and then a prefill which will fill the text box.
input = ""
# assert input == type("String")
input = easygui.enterbox(prompt, title="Input", default = prefill)
if input is None:
input = prefill
#returns the input from the user in the form of a string
return input
# States of operation
def printStartScreen():
columns = shutil.get_terminal_size()[0]
lineBreak(columns, getConfig(4))
printColor("Welcome to NOTEWORTHY, select what you want to do", getConfig(2), "")
lineBreak(columns, getConfig(4))
print("\n")
printColor("0. Exit NOTEWORTHY", 15)
printColor("1. Open app", 15)
printColor("2. Settings", 15)
printColor("3. Help", 15)
def printAppUse():
columns = shutil.get_terminal_size()[0]
lineBreak(columns, getConfig(4))
printColor("AppUse", getConfig(2))
lineBreak(columns, getConfig(4))
printColor("0. Go back", getConfig(2),"")
printColor("1. New Note", getConfig(2),"")
printColor("2. Edit Note", getConfig(2),"")
printColor("3. Search Notes",getConfig(2),"")
printColor("4. List Notes",getConfig(2),"")
printColor("5. Delete Note",getConfig(2),"")
printColor("6. Tag Menu", getConfig(2),"")
printColor("7. Convert Note to MKDown",getConfig(2))
def printSettings():
columns = shutil.get_terminal_size()[0]
lineBreak(columns, getConfig(4))
printColor("Settings", 15, "\n")
printColor("To edit, enter the number of the feature you wish to edit.", 15)
lineBreak(columns, getConfig(4))
printColor("0. Go back", 15)
printColor("1. Pro mode: " + getConfig(6), 15, "")
printColor("2. Change Primary Color (WARNING: Opens a menu)", 15)
printColor("3. Change Secondary Color (WARNING: Opens a menu)", 15)
def printHelpScreen():
columns = shutil.get_terminal_size()[0]
lineBreak(columns,getConfig(4))
printColor("Help", getConfig(2))
printColor("Version: v0.02", getConfig(2))
printColor("If this is your first time using Noteworthy in a long while, it is recommended to check the github at https://github.com/Chrisvann1/Software-Engineering-Note-Taking-Application/ for updates.", getConfig(2))
printColor("Found issues can be reported at the github link.", getConfig(2))
printColor("Go to settings on the homepage to change color and to turn off/on Pro mode.", getConfig(2))
printColor("Function Help:", getConfig(2))
printColor("Date format: YYYY-MM-DD", getConfig(2),"")
printColor("Be careful when selecting an option as escaping without running the function is currently not possible.", getConfig(2),"")
printColor("Make sure when adding tags you seperate them by commas.", getConfig(2),"")
lineBreak(columns, getConfig(4))
printColor("0. Go back", 15)
def printTagMenu():
columns = shutil.get_terminal_size()[0]
lineBreak(columns, getConfig(4))
printColor("Tag Management", getConfig(2))
lineBreak(columns, getConfig(4))
printColor("0. Go back", getConfig(2), "")
printColor("1. Add a tag", getConfig(2), "")
printColor("2. Delete a tag", getConfig(2), "")
printColor("3. List all tags", getConfig(2), "")
printColor("4. Search for a tag", getConfig(2), "")
printColor("5. Rename a tag", getConfig(2))
# The runtime funciton, (acts as a main loop)
def runtime(state):
while(True):
clearConsole()
columns = shutil.get_terminal_size()[0]
match (state):
#Close app
case -1:
clearConsole()
return
# Start page
case 0:
printStartScreen()
case 10 | 20 | 30:
printStartScreen()
state = 0
# Application-in-use page
case 1:
printAppUse()
case 110 | 120 | 130 | 140 | 150 | 160 | 170:
printAppUse()
state = 1
#newNote
case 11:
lineBreak(columns, getConfig(4))
printColor("Creating note...", getConfig(2))
lineBreak(columns, getConfig(4))
printColor("What would you like to name your new note?",getConfig(2), "")
newNoteName = input(": ")
while newNoteName == "":
printColor("The notes name cannot be empty. Please input a name.", getConfig(2))
newNoteName = input(": ")
printColor("What content would you like to add to start? (If you wish to add content later, enter '*END'.)", getConfig(2),"")
printColor("*END: Stop typing to file. (Needs to be on its own line)",getConfig(2),"")
printColor("return key: start a new line.",getConfig(2),"\n")
newContent1 = []
while True:
notes = input("")
if notes == "*END":
break
newContent1.append(notes)
newContent = ""
for line in newContent1:
newContent += line + "\n"
apiCalls.createNote(newNoteName,newContent)
printColor("Would you like to add any tags? (Seperate tags with commas and a space. If none or you wish to add later, enter 'none'.)",getConfig(2),"")
newTags = input(": ")
while newTags != 'none' and not all(tag.strip() for tag in newTags.split(',')):
printColor("Tags should be separated by commas and a space. Please enter tags in the correct format.", getConfig(2))
newTags = input(": ")
newTagList = newTags.split(", ")
if(newTags == 'none'):
lineBreak(columns, getConfig(4))
printColor("Note Created!",getConfig(2))
time.sleep(2)
clearConsole()
printAppUse()
state = 1
else:
apiCalls.addTag(newNoteName,newTagList)
lineBreak(columns,getConfig(4))
printColor("Note Created!", getConfig(2))
time.sleep(2)
clearConsole()
printAppUse()
state = 1
#editNote
case 12:
lineBreak(columns, getConfig(4))
printColor("Editing a note...",getConfig(2))
lineBreak(columns, getConfig(4))
printColor("0. Go back",getConfig(2),"")
printColor("1. New Content",getConfig(2),"")
printColor("2. Edit Content",getConfig(2),"")
printColor("3. Add tags to note",getConfig(2),"")
printColor("4. Delete tags from note", getConfig(2))
#addContent
case 121:
lineBreak(columns, getConfig(4))
printColor("Adding new content...",getConfig(2))
lineBreak(columns, getConfig(4))
printColor("What is the name of the note you wish to change?",getConfig(2),"")
contentName = input(": ")
while contentName == "":
printColor("The note name cannot be empty. Please input a valid name.",getConfig(2))
contentName = input(": ")
printColor("Write the content to wish to add.",getConfig(2),"")
printColor("*END: Stop typing to file.",getConfig(2),"")
printColor("return key: start a new line.",getConfig(2),"")
addContent1 = []
addContent = ""
while True:
notes = input("")
if notes == "*END":
break
addContent1.append(notes)
for line in addContent1:
addContent += line + "\n"
apiCalls.addContent(contentName,addContent)
lineBreak(columns, getConfig(4))
printColor("Added content!",getConfig(2))
time.sleep(2)
clearConsole()
printAppUse()
state = 1
#editContent
case 122:
lineBreak(columns, getConfig(4))
printColor("Coming in v0.02.",getConfig(2))
lineBreak(columns, getConfig(4))
printColor("What is the name of the note you wish to edit?",getConfig(2),"")
contentName = input(": ")
while contentName == "":
printColor("The note name cannot be empty. Please input a valid name.", getConfig(2))
contentName = input(": ")
search_response = apiCalls.searchNotes('title', contentName, ['content'])
note_content = translation(search_response.content)
newContent = input_pre_filled("Edit the note", note_content)
apiCalls.addContent(contentName, newContent)
lineBreak(columns, getConfig(4))
printColor("Edits saved",getConfig(2))
time.sleep(2)
clearConsole()
printAppUse()
state = 1
#addTag
case 123:
lineBreak(columns, getConfig(4))
printColor("Adding tag...",getConfig(2),"")
lineBreak(columns, getConfig(4))
printColor("What is the name of the note you wish to add a tag to?",getConfig(2),"")
addTagName = ""
while addTagName == "":
printColor("The note to add to cannot be empty. Please input a name.", getConfig(2))
addTagName = input(": ")
printColor("What is the tags that you wish to add? (List with commas and a space inbetween)", getConfig(2),"")
addTags = input(": ")
while addTags != 'none' and not all(tag.strip() for tag in newTags.split(',')):
printColor("Tags should be separated by commas and a space. Please enter tags in the correct format.", getConfig(2))
addTags = input(": ")
tagsList = addTags.split(", ")
apiCalls.addTag(addTagName,tagsList)
lineBreak(columns, getConfig(4))
printColor("Added tag(s)!", getConfig(2))
time.sleep(2)
clearConsole()
printAppUse()
state = 1
#deleteTag
case 124:
lineBreak(columns, getConfig(4))
printColor("Deleting tag...",getConfig(2),"")
lineBreak(columns, getConfig(4))
printColor("What is the name of the note you wish to edit?",getConfig(2),"")
delTagName = input(": ")
while delTagName == "":
printColor("The note to remove a tag from to cannot be empty. Please input a name.", getConfig(2))
addTagName = input(": ")
printColor("What is the tags that you wish to delete? (List with commas and a space inbetween)", getConfig(2),"")
delTags = input(": ")
while addTags != 'none' and not all(tag.strip() for tag in newTags.split(',')):
printColor("Tags should be separated by commas and a space. Please enter tags in the correct format.", getConfig(2))
delTags= input(": ")
delTagsList = delTags.split(", ")
apiCalls.deletetag(delTagName,delTagsList)
lineBreak(columns, getConfig(4))
printColor("Deleted tag(s)!",getConfig(2))
time.sleep(2)
clearConsole()
printAppUse()
state = 1
#addImage
case 125:
lineBreak(columns, getConfig(4))
printColor("Adding image...",getConfig(2),"")
lineBreak(columns, getConfig(4))
printColor("What is the name of the note you wish to edit?",getConfig(2),"")
noteTitle = input(": ")
while noteTitle == "":
printColor("The note to add an image to cannot be empty. Please input a name.", getConfig(2))
printColor("What are the paths to the images you would like to attach? (List with commas between)", getConfig(2),"")
imagePathInput = input(": ")
imagePaths = imagePathInput.split(",")
apiCalls.addImage(noteTitle, imagePaths)
lineBreak(columns, getConfig(4))
printColor("Added image(s)!", getConfig(2))
time.sleep(2)
clearConsole()
printAppUse()
state = 1
#searchNotes
case 13:
lineBreak(columns, getConfig(4))
printColor("What do you want to search by?",getConfig(2))
lineBreak(columns, getConfig(4))
printColor("0. Go back",getConfig(2),"")
printColor("1. View content", getConfig(2),"")
printColor("2. By title", getConfig(2),"")
printColor("3. By created date",getConfig(2),"")
printColor("4. By modified date",getConfig(2),"")
printColor("5. By tag",getConfig(2))
case 1310 | 1320 | 1330 | 1340 | 1350:
printAppUse()
state = 1
#view_content
case 131:
pass
lineBreak(columns, getConfig(4))
printColor("Enter title that you wish to view content of.",getConfig(2))
lineBreak(columns, getConfig(4))
search_by = input(": ")
while search_by == "":
printColor("The note to search for to cannot be empty. Please input a name.", getConfig(2))
search_by = input(": ")
desired_response = ['title','content']
api_response = apiCalls.searchNotes('title', search_by, desired_response)
entries = translation(api_response.content)
parsing = entries.split("\n")
test_split = parsing[1].replace(r'\n','\n')
repeats = len(test_split)
x=1
printColor("File Name: ", getConfig(2))
print(" " + parsing[x-1])
printColor("Content: ", getConfig(2))
print(" " + test_split)
#title
case 132:
lineBreak(columns, getConfig(4))
printColor("Enter title to search.",getConfig(2))
lineBreak(columns, getConfig(4))
search_by = input(": ")
while search_by == "":
printColor("The note to search for cannot be empty. Please input a name.", getConfig(2))
search_by = input(": ")
desired_response = ['title','modified_date','created_date']
api_response = apiCalls.searchNotes('title', search_by, desired_response)
entries = translation(api_response.content)
parsing = entries.split("\n")
repeats = len(parsing)
x = 1
while x < repeats:
printColor("File Name: ", getConfig(2))
print(" " + parsing[x-1])
printColor("Created Date: ", getConfig(2))
print(" " + parsing[x])
printColor("Modified Date: ", getConfig(2))
print(" " + parsing[x+1])
print("\n")
x = x+3
#created_date
case 133: #Currently not working
lineBreak(columns, getConfig(4))
printColor("Enter the beginning of the date range to search by.",getConfig(2))
lineBreak(columns, getConfig(4))
start = input(": ")
while start == "":
printColor("The date range to search by cannot be empty. Please input a date.", getConfig(2))
start = input(": ")
lineBreak(columns, getConfig(4))
printColor("Enter the end of the date range to search by.",getConfig(2))
lineBreak(columns, getConfig(4))
end = input(": ")
while end == "":
printColor("The date range to search by cannot be empty. Please input a date.", getConfig(2))
end = input(": ")
desired_response = ['title','modified_date','created_date']
api_response = apiCalls.searchNotes('created_date', "", desired_response, start, end)
entries = translation(api_response.content)
parsing = entries.split("\n")
repeats = len(parsing)
x = 1
while x < repeats:
printColor("File Name: ", getConfig(2))
print(" " + parsing[x-1])
printColor("Created Date: ", getConfig(2))
print(" " + parsing[x])
printColor("Modified Date: ", getConfig(2))
print(" " + parsing[x+1])
print("\n")
x = x+3
#modified_date
case 134: #Currently not working
lineBreak(columns, getConfig(4))
printColor("Enter the beginning of the date range to search by.",getConfig(2))
lineBreak(columns, getConfig(4))
start = input(": ")
while start == "":
printColor("The date range to search by cannot be empty. Please input a date.", getConfig(2))
start = input(": ")
lineBreak(columns, getConfig(4))
printColor("Enter the end of the date range to search by.",getConfig(2))
lineBreak(columns, getConfig(4))
end = input(": ")
while end == "":
printColor("The date range to search by cannot be empty. Please input a date.", getConfig(2))
end = input(": ")
desired_response = ['title','modified_date','created_date']
api_response = apiCalls.searchNotes('modified_date', "", desired_response, start, end)
entries = translation(api_response.content)
parsing = entries.split('\n')
repeats = len(parsing)
x = 1
while x < repeats:
printColor("File Name: ", getConfig(2))
print(" " + parsing[x-1])
printColor("Created Date: ", getConfig(2))
print(" " + parsing[x])
printColor("Modified Date: ", getConfig(2))
print(" " + parsing[x+1])
print("\n")
x = x+3
#search by tag
case 135:
lineBreak(columns, getConfig(4))
printColor("Enter tag to search.", getConfig(2))
lineBreak(columns, getConfig(4))
search_by = input(": ")
while search_by == "":
printColor("The tag to search for cannot be empty. Please input a tag name.", getConfig(2))
search_by = input(": ")
desired_response = ['title', 'tag']
api_response = apiCalls.searchNotesByTag(search_by, desired_response)
entries = translation(api_response.content)
parsing = entries.split('\n')
repeats = len(parsing)
x = 1
#y = 1
while x < repeats:
printColor("File Name: ", getConfig(2))
print(" " + parsing[x-1])
printColor("Note Tag: ", getConfig(2))
print(" " + parsing[x])
print("\n")
x = x+2
#listNotes
case 14:
lineBreak(columns, getConfig(4))
printColor("Listing notes...",getConfig(2))
lineBreak(columns, getConfig(4))
printColor("0. Go back",getConfig(2),"")
printColor("1. By title",getConfig(2),"")
printColor("2. By created date",getConfig(2),"")
printColor("3. By modified date",getConfig(2),"")
printColor("4. List Tags", getConfig(2))
case 1410 | 1420 | 1430 | 1440:
printAppUse()
state = 1
#list notes by title
case 141:
lineBreak(columns, getConfig(4))
printColor("Listing notes by title...",getConfig(2))
lineBreak(columns, getConfig(4))
gotList = apiCalls.listNotes("title")
#printing the response
entries = translation(gotList.content)
parsing = entries.split('\n')
repeats = len(parsing)
x = 1
while x < repeats:
printColor("File Name: ", getConfig(2))
print(" " + parsing[x-1])
x = x+1
#list notes by created date
case 142:
lineBreak(columns, getConfig(4))
printColor("Listing notes by created date...",getConfig(2))
lineBreak(columns, getConfig(4))
gotList = apiCalls.listNotes("created_date")
#printing the response
entries = translation(gotList.content)
parsing = entries.split('\n')
repeats = len(parsing)
x = 1
while x < repeats:
printColor("File Name: \n", getConfig(2),"")
print(" " + parsing[x-1])
printColor("Created Date: ", getConfig(2))
print(" " + parsing[x])
x = x+2
#list notes by modified date
case 143:
lineBreak(columns, getConfig(4))
printColor("Listing notes by modified date...",getConfig(2))
lineBreak(columns, getConfig(4))
gotList = apiCalls.listNotes("modified_date")
#printing the response
entries = translation(gotList.content)
parsing = entries.split('\n')
repeats = len(parsing)
x = 1
while x < repeats:
printColor("File Name: \n", getConfig(2),"")
print(" " + parsing[x-1])
printColor("Modified Date: ", getConfig(2))
print(" " + parsing[x])
x = x+2
#list all tags
case 144: #Currently not working
tags = apiCalls.listTags()
print(tags)
#printColor("Tags:\n" + "\n".join([f"{tag['title']}: {tag['tag']}" for tag in tags]), getConfig(2))
time.sleep(2)
state = 1
#deleteNote
case 15:
lineBreak(columns, getConfig(4))
printColor("Deleting note...", getConfig(2))
lineBreak(columns, getConfig(4))
printColor("Enter the name of the note you wish to delete.",getConfig(2),"")
delNoteName = input(": ")
apiCalls.deleteNote(delNoteName)
printColor("Note deleted or it already does not exist", getConfig(2))
time.sleep(2)
clearConsole()
printAppUse()
state = 1
#Tag menu stuff
case 16: #Unsure if tag menu stuff is working as search and list is not working.
printTagMenu()
case 1640:
printAppUse()
state = 1
case 161:
lineBreak(columns, getConfig(4))
printColor("Adding tag...",getConfig(2),"")
lineBreak(columns, getConfig(4))
printColor("What is the name of the note you wish to edit?",getConfig(2),"")
addTagName = input(": ")
while addTagName == "":
printColor("The note to search for cannot be empty. Please input a note name.", getConfig(2))
addTagName = input(": ")
printColor("What is the tags that you wish to add? (List with commas and a space inbetween)", getConfig(2),"")
addTags = input(": ")
while addTags != 'none' and not all(tag.strip() for tag in newTags.split(',')):
printColor("Tags should be separated by commas and a space. Please enter tags in the correct format.", getConfig(2))
addTags = input(": ")
tagsList = addTags.split(", ")
apiCalls.addTag(addTagName,tagsList)
lineBreak(columns, getConfig(4))
printColor("Added tag(s)!", getConfig(2))
time.sleep(2)
clearConsole()
printAppUse()
state = 1
case 162:
lineBreak(columns, getConfig(4))
printColor("Deleting tag...",getConfig(2),"")
lineBreak(columns, getConfig(4))
printColor("What is the name of the note you wish to edit?",getConfig(2),"")
delTagName = input(": ")
while delTagName == "":
printColor("The tag to search for cannot be empty. Please input a tag name.", getConfig(2))
delTagName = input(": ")
printColor("What is the tags that you wish to delete? (List with commas and a space inbetween)", getConfig(2),"")
delTags = input(": ")
while delTags != 'none' and not all(tag.strip() for tag in newTags.split(',')):
printColor("Tags should be separated by commas and a space. Please enter tags in the correct format.", getConfig(2))
delTags = input(": ")
delTagsList = delTags.split(", ")
print(delTagsList[1])
apiCalls.deletetag(delTagName,delTagsList)
lineBreak(columns, getConfig(4))
printColor("Deleted tag(s)!",getConfig(2))
time.sleep(2)
clearConsole()
printAppUse()
state = 1
case 163:
tags = apiCalls.listTags()
#printColor("Tags:\n" + "\n".join([f"{tag['title']}: {tag['tag']}" for tag in tags]), getConfig(2))
time.sleep(2)
state = 1
case 164:
lineBreak(columns, getConfig(4))
printColor("Enter tag to search.", getConfig(2))
lineBreak(columns, getConfig(4))
search_by = input(": ")
while search_by == "":
printColor("The tag to search by cannot be empty. Please input a tag name.", getConfig(2))
search_by = input(": ")
desired_response = ['title', 'tag']
api_response = apiCalls.searchNotesByTag(search_by, desired_response)
entries = translation(api_response.content)
parsing = entries.split('\n')
repeats = len(parsing)
x = 1
#y = 1
while x < repeats:
printColor("File Name: ", getConfig(2))
print(" " + parsing[x-1])
printColor("Note Tag: ", getConfig(2))
print(" " + parsing[x])
print("\n")
x = x+2
case 165:
printColor("Renaming a tag...", getConfig(2))
lineBreak(columns, getConfig(4))
printColor("Enter the current tag name:", getConfig(2))
old_tag = input(": ")
while old_tag == "":
printColor("The tag to rename cannot be empty. Please input a tag name.", getConfig(2))
old_tag = input(": ")
printColor("Enter the new tag name:", getConfig(2))
new_tag = input(": ")
while new_tag == "":
printColor("The new name cannot be empty. Please input a tag name.", getConfig(2))
new_tag = input(": ")
apiCalls.renameTag(old_tag, new_tag)
lineBreak(columns, getConfig(4))
printColor("Tag renamed successfully!", getConfig(2))
time.sleep(2)
clearConsole()
printAppUse()
state = 1
# Convert Notes To MKDown
case 17: #Unsure if working, can writer please tell me if working
lineBreak(columns, getConfig(4))
printColor("What is the title of the note you would like to convert to MKDown?",getConfig(2), "")
lineBreak(columns,getConfig(4))
search_by = input(": ")
while search_by == "":
printColor("The note to search for cannot be empty. Please input a note name.", getConfig(2))
search_by = input(": ")
desired_response = ['content']
api_response = apiCalls.searchNotes('title', search_by, desired_response)
entries = translation(api_response.content)
parsing = entries.split("\n")
content = parsing[1].replace(r'\n', '\n')
title = parsing[0]
if ".md" not in title:
title = title + ".md"
apiCalls.mdDownConversion(title, content)
printColor("Note converted successfully!", getConfig(2))
time.sleep(2)
clearConsole()
printAppUse()
state = 1
# Settings page
case 2:
printSettings()
case 210 | 220 | 230:
printSettings()
state = 2
# Change status of pro mode
case 21:
print("Currently pro mode is "
+ "on" if int(getConfig(6)) == 1 else "off"
+ " to turn it "
+ "off" if int(getConfig(6)) == 1 else "on"
+ " enter"
+ "0" if int(getConfig(6)) == 1 else "1")
response = input(": ")
while response != 1 and response != 0:
printColor("Please enter a number")
response = input(": ")
setConfig(6)
clearConsole()
lineBreak(columns, 15)
printColor("Success, enter 0 to go back", getConfig(2))
lineBreak(columns, 15)
# Primary color selection
case 22:
lineBreak(columns, 15)
print("Choose a primary color")
printColor("current color", getConfig(2))
lineBreak(columns, 15)
optionColors()
print("\n")
lineBreak(columns, 15)
printColor("To select, enter the number pertaining to the color you want.", 15)
newColor = input(": ")
while int(newColor) not in range(1,256):
printColor("Please enter a number")
newColor = input(": ")
setConfig(2,newColor)
clearConsole()
lineBreak(columns, getConfig(4))
printColor("Success, enter 0 to go back", getConfig(2))
lineBreak(columns, getConfig(4))
# Secondary color selection
case 23:
lineBreak(columns, 15)
print("Choose a secondary color")
printColor("current color", getConfig(4))
lineBreak(columns, 15)
optionColors()
print("\n")
lineBreak(columns, 15)
printColor("To select, enter the number pertaining to the color you want.", 15)
newColor = input(": ")
while int(newColor) not in range(1,256):
printColor("Please enter a number", getConfig(2))
newColor = input(": ")
setConfig(4,newColor)
clearConsole()
lineBreak(columns, getConfig(4))
printColor("Success, enter 0 to go back", getConfig(2))
lineBreak(columns, getConfig(4))
# General Help page
case 3:
printHelpScreen()
# Fall through error case
case 999:
printColor("Invalid state", 9)
break
userInput = input(": ")
if userInput != "":
if (state == 0 and userInput == '0'):
state = -1
else:
while True:
if userInput.isdigit():
userInputFixed = int(userInput)
if 0 <= userInputFixed <= 9:
state = (state * 10) + userInputFixed
break
else:
printColor("Invalid input. Please enter a number between 0 and 9.", getConfig(2))
userInput = input(": ")
else:
printColor("Invalid input. Please enter a number between 0 and 9.", getConfig(2))
userInput = input(": ")
# Runtime
runtime(0)