Skip to content

Commit

Permalink
less: Add highlight feature for search
Browse files Browse the repository at this point in the history
Signed-off-by: iipeace <[email protected]>
  • Loading branch information
iipeace committed Jan 27, 2024
1 parent fb76d70 commit e8bce25
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions guider/guider.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
__credits__ = "Peace Lee"
__license__ = "GPLv2"
__version__ = "3.9.8"
__revision__ = "240126"
__revision__ = "240127"
__maintainer__ = "Peace Lee"
__email__ = "[email protected]"
__repository__ = "https://github.com/iipeace/guider"
Expand Down Expand Up @@ -25846,6 +25846,7 @@ class SysMgr(object):
maxBlkRd = 0
maxBlkWr = 0
maxCpuUsage = 0
maxCpuSteal = 0
maxGpuMemUsage = 0
maxGpuUsage = 0
maxInterval = 0
Expand Down Expand Up @@ -28207,6 +28208,7 @@ def clearStats():
SysMgr.maxBlkRd = 0
SysMgr.maxBlkWr = 0
SysMgr.maxCpuUsage = 0
SysMgr.maxCpuSteal = 0
SysMgr.maxGpuMemUsage = 0
SysMgr.maxGpuUsage = 0
SysMgr.maxInterval = 0
Expand Down Expand Up @@ -28246,6 +28248,7 @@ def getPeakList(incInter=True):
"blkRdMB": SysMgr.maxBlkRd,
"blkWrMB": SysMgr.maxBlkWr,
"cpuPer": SysMgr.maxCpuUsage,
"cpuStealPer": SysMgr.maxCpuSteal,
"diskFreeMB": SysMgr.minDiskFree,
"gpuPer": SysMgr.maxGpuUsage,
"gpumemMB": SysMgr.maxGpuMemUsage,
Expand Down Expand Up @@ -28445,6 +28448,7 @@ def doLess(inputArg=None):
wbuf = []
cursor = 0
lastWord = ""
colorWord = ""

# check input #
if inputArg:
Expand Down Expand Up @@ -28477,9 +28481,18 @@ def doLess(inputArg=None):

def _printPage(wbuf, cursor):
SysMgr.clearScreen()
SysMgr.printPipe(
wbuf[cursor : cursor + SysMgr.ttyRows - 2], pager=False
)

pbuf = wbuf[cursor : cursor + SysMgr.ttyRows - 2]

# apply color #
if colorWord:
coloredWord = UtilMgr.convColor(colorWord, "REVERSE")
for pidx in range(len(pbuf)):
pbuf[pidx] = UtilMgr.removeColor(pbuf[pidx]).replace(
colorWord, coloredWord
)

SysMgr.printPipe(pbuf, pager=False)

def _readPipe(wbuf, pipeInput):
while 1:
Expand Down Expand Up @@ -28657,6 +28670,8 @@ def _handleInput(key, cursor, wbuf, lastWord, lastKey):
cursor, lastWord, lastKey = _handleInput(
k.strip(), cursor, wbuf, lastWord, lastKey
)
if lastWord:
colorWord = lastWord

# clear screen and print a page #
_printPage(wbuf, cursor)
Expand Down Expand Up @@ -132072,9 +132087,12 @@ def printSystemUsage(self):
or (peakUptime and SysMgr.uptime >= peakUptime)
or (peakRuntime and SysMgr.getRuntime(sec=True) >= peakRuntime)
):
# CPU #
# CPU usage #
SysMgr.maxCpuUsage = max(SysMgr.maxCpuUsage, totalUsage)

# CPU steal #
SysMgr.maxCpuSteal = max(SysMgr.maxCpuSteal, stealUsage)

# GPU #
try:
SysMgr.maxGpuUsage = max(
Expand Down

0 comments on commit e8bce25

Please sign in to comment.