From bf6f3b184673b89f52a35a61bcbf918ca2f1f027 Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Tue, 15 May 2018 10:47:55 -0400 Subject: [PATCH 1/7] Update pyfancy.py --- pyfancy/pyfancy.py | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/pyfancy/pyfancy.py b/pyfancy/pyfancy.py index 23996fa..aca178b 100644 --- a/pyfancy/pyfancy.py +++ b/pyfancy/pyfancy.py @@ -1,25 +1,11 @@ -# Provides methods for manipulating text styling in specific terminals. -# Uses a basic chaining method where text properties are added by calling -# methods with related names. +# Pyfancy 3.dev # -# For example, to print "Hello, world!" in red: -# print pyfancy().red("Hello, world!").get() +# Pyfancy 3 will allow not only focus on terminal color styling +# but become the one stop shop for terminal interactions. # -# Styles can be changed for different text components. Example: -# print pyfancy().red("Hello").raw(", ").blue("world!").get() -# -# No output text is necessary when calling a styling method. This allows -# styles to be stacked: -# print pyfancy().red().bold("Hello, world!").get() -# -# There are two provided ways to access the modified text. The first is -# direct access to the string object called "out". However, accessing this -# object will not reset the style, so any text outputted after will have -# the same style as whatever the text was at the end of the chain. -# -# The get() method is better for accessing text because it resets the text -# style so no new text will have unwanted styling. +# Join the discussion: https://github.com/ilovecode1/Pyfancy-2/issues/51 +import os class pyfancy: @@ -96,6 +82,18 @@ def read(self, file): self.parse(f.read()) f.close() return self + + def next(self, times=1): + self.out += ('\n' * times) + return self + + def clear(self): + if os.name == "posix": + os.system('clear') + elif os.name in ("nt", "dos", "ce"): + os.system('CLS') + else: + print('\n' * 100) def reset(self): self.out = '' @@ -191,7 +189,7 @@ def multi(self, string): i = 31 # ID of escape code; starts at 31 (red) and goes to 36 (cyan) for c in string: # Iterate through string self.out += '\033[' + str(i) + 'm' + c - i += 1 # Why u no have ++i? >:( + i += 1 if(i > 36): i = 31 return self @@ -200,7 +198,6 @@ def multi(self, string): # and formatting code # This shouldn't be exported - def _add(name, number): def inner(self, addition=''): self.out += '\033[%dm%s' % (number, addition) From b0700764d97c9e8efde82d68bb7bbe1671ca0b2b Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Tue, 15 May 2018 10:49:32 -0400 Subject: [PATCH 2/7] Rename CODE_OF_CONDUCT.md to .github/CODE_OF_CONDUCT.md --- CODE_OF_CONDUCT.md => .github/CODE_OF_CONDUCT.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename CODE_OF_CONDUCT.md => .github/CODE_OF_CONDUCT.md (100%) diff --git a/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md similarity index 100% rename from CODE_OF_CONDUCT.md rename to .github/CODE_OF_CONDUCT.md From 385fd1678f396047c3847ac1de9c922fd465b9d7 Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Tue, 15 May 2018 10:50:00 -0400 Subject: [PATCH 3/7] Rename CONTRIBUTING.md to .github/CONTRIBUTING.md --- CONTRIBUTING.md => .github/CONTRIBUTING.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename CONTRIBUTING.md => .github/CONTRIBUTING.md (100%) diff --git a/CONTRIBUTING.md b/.github/CONTRIBUTING.md similarity index 100% rename from CONTRIBUTING.md rename to .github/CONTRIBUTING.md From 502b1ebc7d98fd9a52d36030e1499a3dbb2977e9 Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Tue, 15 May 2018 10:50:36 -0400 Subject: [PATCH 4/7] Rename ISSUE_TEMPLATE.md to .github/ISSUE_TEMPLATE.md --- ISSUE_TEMPLATE.md => .github/ISSUE_TEMPLATE.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename ISSUE_TEMPLATE.md => .github/ISSUE_TEMPLATE.md (100%) diff --git a/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md similarity index 100% rename from ISSUE_TEMPLATE.md rename to .github/ISSUE_TEMPLATE.md From 9f84dd165b9f3dabf84ff1edeb308ccf3effb329 Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Tue, 15 May 2018 10:51:13 -0400 Subject: [PATCH 5/7] Rename PULL_REQUEST_TEMPLATE.md to .github/PULL_REQUEST_TEMPLATE.md --- PULL_REQUEST_TEMPLATE.md => .github/PULL_REQUEST_TEMPLATE.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename PULL_REQUEST_TEMPLATE.md => .github/PULL_REQUEST_TEMPLATE.md (100%) diff --git a/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md similarity index 100% rename from PULL_REQUEST_TEMPLATE.md rename to .github/PULL_REQUEST_TEMPLATE.md From 11ad5fa607e08c58b413cb9a892fbc887ab630f2 Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Tue, 15 May 2018 10:51:44 -0400 Subject: [PATCH 6/7] Rename NOTICE.md to .github/NOTICE.md --- NOTICE.md => .github/NOTICE.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename NOTICE.md => .github/NOTICE.md (100%) diff --git a/NOTICE.md b/.github/NOTICE.md similarity index 100% rename from NOTICE.md rename to .github/NOTICE.md From b03a6d38595b08feff7d575cea04c572e8acb98d Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Tue, 15 May 2018 10:55:00 -0400 Subject: [PATCH 7/7] Update demo.py --- pyfancy/demo.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyfancy/demo.py b/pyfancy/demo.py index 8f30c0b..ec0f124 100644 --- a/pyfancy/demo.py +++ b/pyfancy/demo.py @@ -1,5 +1,6 @@ from pyfancy import pyfancy +pyfancy().clear() pyfancy().red("Hello").raw(", ").blue("world!").output() pyfancy().multi("Multicolored text").output() pyfancy().rainbow("Rainbow text").output() @@ -14,4 +15,5 @@ pyfancy().black().gray_bg("Gray background").output() pyfancy().read("pyfancy/demo/import.txt").output() pyfancy().red("This should not be seen!").reset().output() +pyfancy().blue("this").next().red("and").next(3).green("that") print(pyfancy().red("Hello").raw(", ").blue("world!").strip())