Skip to content

Commit

Permalink
Copy button in the terminal IndianOpenSourceFoundation#177 (Update_3)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aspireve committed Jul 30, 2022
1 parent bafd955 commit 19063e2
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions dynamic/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,12 @@ def navigate_questions_panel(self, playbook=False):
self, self.questions_data[options_index][1]
)
elif question_menu.chosen_accept_key == "c":
code = ""
code = "" # "code" will be edited later
i = 0
flag = False
self.dbmd = "'''" + self.dbmd + "'''"
self.dbmd = "'''" + self.dbmd + "'''"
#to avoid situstion where text break due to any other colons in the middle
while i <len(self.dbmd):
a = self.dbmd[i]
counter = 0
if self.dbmd[i] == " ":
while(i<len(self.dbmd)):
Expand All @@ -328,26 +328,29 @@ def navigate_questions_panel(self, playbook=False):
i += 1
else:
break
# checks if there are 4 spaces, the basic format for a markdown code input
if (counter>0) and (counter % 4 == 0):
flag = True
# once code beginning is found we go till the end of that code only and stop where that snippet stops
while((self.dbmd[i] != '\n' and self.dbmd[i] != '\r') and i+1 < len(self.dbmd) ):
code += self.dbmd[i]
#the word attach to the code variable
i += 1
while(True):
b = self.dbmd[i]
while(self.dbmd[i] == '\n' or self.dbmd[i] == '\r'):
code += self.dbmd[i]
i+=1
b = self.dbmd[i]
if self.dbmd[i] == " " and self.dbmd[i+1] == " " and self.dbmd[i+2] == " " and self.dbmd[i+3] == " ":
i += 4
#checks if the next 4 spots are spaces aswell indicating continuation of snippet
while((self.dbmd[i] != '\n' and self.dbmd[i] != '\r') and i+1 < len(self.dbmd) ):
code += self.dbmd[i]
i += 1
else:
break
i += 1
if flag:
#breaks if code is finished
break
pc.copy(code)
console.print("\nCopied Sucessfully !!\n")
Expand Down

0 comments on commit 19063e2

Please sign in to comment.