Skip to content

Commit

Permalink
v35.16; support less and vlc commands on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
eliranwong committed Oct 24, 2023
1 parent 63e6ee7 commit 0027d5d
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 40 deletions.
2 changes: 1 addition & 1 deletion UniqueBibleAppVersion.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
35.15
35.16
3 changes: 3 additions & 0 deletions latest_changes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Changes in 35.16:
* support Windows users to use "less" & "vlc" command with terminal mode.

Changes in 35.15:
* Added support wrap words in terminal mode pager is enabled.

Expand Down
10 changes: 5 additions & 5 deletions patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,6 @@
(34.79, "file", "llama_index/NET_md_index/vector_store.json")
(34.81, "file", "gui/SearchLauncher.py")
(34.82, "file", "gui/MaterialMainWindow.py")
(34.82, "file", "util/VlcUtil.py")
(34.85, "file", "db/AGBTSData.py")
(34.87, "file", "util/AGBsubheadings.py")
(34.88, "file", "util/RemoteHttpHandler.py")
Expand Down Expand Up @@ -1389,7 +1388,8 @@
(35.13, "file", "util/TextCommandParser.py")
(35.13, "file", "util/TextEditorUtility.py")
(35.14, "file", "util/ConfigUtil.py")
(35.15, "file", "util/LocalCliHandler.py")
(35.15, "file", "patches.txt")
(35.15, "file", "UniqueBibleAppVersion.txt")
(35.15, "file", "latest_changes.txt")
(35.16, "file", "util/VlcUtil.py")
(35.16, "file", "util/LocalCliHandler.py")
(35.16, "file", "patches.txt")
(35.16, "file", "UniqueBibleAppVersion.txt")
(35.16, "file", "latest_changes.txt")
48 changes: 16 additions & 32 deletions util/LocalCliHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -894,40 +894,24 @@ def displayOutputOnTerminal(self, content):
html = self.fineTuneTextForWebBrowserDisplay()
self.cliTool("w3m -T text/html -o confirm_qq=false", html)
else:
if config.terminalEnablePager:
if config.terminalWrapWords:
content = self.getWrappedHTMLText(content)
content = TextUtil.convertHtmlTagToColorama(content)
#print(content)
divider = self.divider
if config.terminalEnablePager and not content in ("Command processed!", "INVALID_COMMAND_ENTERED") and not content.endswith("not supported in terminal mode.") and not content.startswith("[MESSAGE]"):
if platform.system() == "Windows":
try:
pydoc.pager(content)
except:
config.terminalEnablePager = False
self.print(divider)
self.print(content)
# When you use remote powershell and want to pipe a command on the remote windows server through a pager, piping through out-host -paging works as desired. Piping through more when running the remote command is of no use: the entire text is displayed at once.
# try:
# pydoc.pipepager(content, cmd='out-host -paging')
# except:
# try:
# pydoc.pipepager(content, cmd='more')
# except:
# config.terminalEnablePager = False
# self.print(divider)
# self.print(content)
else:
try:
# paging without colours
#pydoc.pager(content)
# paging with colours
pydoc.pipepager(content, cmd='less -R')
except:
config.terminalEnablePager = False
self.print(divider)
self.print(content)
try:
if config.terminalWrapWords:
content = self.getWrappedHTMLText(content)
pagerContent = TextUtil.convertHtmlTagToColorama(content)
pydoc.pipepager(pagerContent, cmd='less -R') if WebtopUtil.isPackageInstalled("less") else pydoc.pager(pagerContent)
# Windows users can install less command with scoop
# read: https://github.com/ScoopInstaller/Scoop
# instll scoop
# > iwr -useb get.scoop.sh | iex
# > scoop install aria2
# instll less
# > scoop install less
except:
config.terminalEnablePager = False
self.print(divider)
self.print(content)
else:
if content.startswith("[MESSAGE]"):
content = content[9:]
Expand Down
19 changes: 17 additions & 2 deletions util/VlcUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,22 @@ def playMediaFile(filePath, vlcSpeed, audioGui=False):
# on Windows
if not hasattr(config, "windowsVlc"):
windowsVlc = r'C:\Program Files\VideoLAN\VLC\vlc.exe'
config.windowsVlc = windowsVlc if platform.system() == "Windows" and os.path.isfile(windowsVlc) else ""

if platform.system() == "Windows":
if os.path.isfile(windowsVlc):
config.windowsVlc = windowsVlc
elif VlcUtil.isPackageInstalled("vlc"):
# Windows users can install vlc command with scoop
# read: https://github.com/ScoopInstaller/Scoop
# instll scoop
# > iwr -useb get.scoop.sh | iex
# > scoop install aria2
# install vlc
# > scoop bucket add extras
# > scoop install vlc
config.windowsVlc = "vlc"
else:
config.windowsVlc = ""
# get full path and escape double quote
if isinstance(filePath, str):
filePath = os.path.abspath(filePath).replace('"', '\\"')
Expand All @@ -67,7 +82,7 @@ def playMediaFileVlcNoGui(filePath, vlcSpeed):
command = f'''{config.macVlc} --intf rc --play-and-exit --rate {vlcSpeed} "{filePath}" &> /dev/null'''
# vlc on windows
elif config.windowsVlc:
command = f'''"{config.windowsVlc}" --play-and-exit --rate {vlcSpeed} "{filePath}"'''
command = f'''"{config.windowsVlc}" --intf dummy --play-and-exit --rate {vlcSpeed} "{filePath}"'''
# vlc on other platforms
elif VlcUtil.isPackageInstalled("cvlc"):
command = f'''cvlc --play-and-exit --rate {vlcSpeed} "{filePath}" &> /dev/null'''
Expand Down

0 comments on commit 0027d5d

Please sign in to comment.