From 3832c0c72b239730f77f746c6c4cfb4a7eda4990 Mon Sep 17 00:00:00 2001 From: chenxinquan Date: Fri, 18 Nov 2022 15:40:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=95=8C=E9=9D=A2=E9=94=99?= =?UTF-8?q?=E8=AF=AF=EF=BC=8C=E5=AE=8C=E6=88=90=E5=B8=83=E5=B1=80=E7=BC=96?= =?UTF-8?q?=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gconsole/FrameReportKBind.go | 53 ++++++++++++++++++++++++++++++++ src/gconsole/FrameReportView.go | 32 +++++++++++++------ src/gconsole/gconsole.go | 5 +++ 3 files changed, 80 insertions(+), 10 deletions(-) diff --git a/src/gconsole/FrameReportKBind.go b/src/gconsole/FrameReportKBind.go index 8d64337..8f10963 100644 --- a/src/gconsole/FrameReportKBind.go +++ b/src/gconsole/FrameReportKBind.go @@ -200,6 +200,59 @@ func (fr *FrameReport)KeyBinding(g *gocui.Gui) error { FRAMEREPORTVIEW_VIEWNAME_VULNINFO, gocui.KeyEnter, gocui.ModNone, fr.NextView)) + // FRAMEREPORTVIEW_VIEWNAME_REPORT + rcs = append(rcs, g.SetKeybinding( + FRAMEREPORTVIEW_VIEWNAME_REPORT, + gocui.KeyTab, gocui.ModNone, fr.NextView)) + rcs = append(rcs, g.SetKeybinding( + FRAMEREPORTVIEW_VIEWNAME_REPORT, + gocui.KeyCtrlQ, gocui.ModNone, fr.PreView)) + rcs = append(rcs, g.SetKeybinding( + FRAMEREPORTVIEW_VIEWNAME_REPORT, + gocui.KeyCtrlH, gocui.ModNone, fr.NextView)) + // rcs = append(rcs, g.SetKeybinding(FRAMEREPORTVIEW_VIEWNAME_REPORT, gocui.KeyCtrlL, gocui.ModNone, fr.NextView)) + // rcs = append(rcs, g.SetKeybinding(FRAMEREPORTVIEW_VIEWNAME_REPORT, gocui.KeyArrowUp, gocui.ModAlt, fr.PreView)) + // rcs = append(rcs, g.SetKeybinding(FRAMEREPORTVIEW_VIEWNAME_REPORT, gocui.KeyArrowLeft, gocui.ModAlt, fr.NextView)) + rcs = append(rcs, g.SetKeybinding( + FRAMEREPORTVIEW_VIEWNAME_REPORT, + gocui.KeyArrowDown, gocui.ModNone, fr.CursorDown)) + rcs = append(rcs, g.SetKeybinding( + FRAMEREPORTVIEW_VIEWNAME_REPORT, + gocui.KeyArrowUp, gocui.ModNone, fr.CursorUp)) + rcs = append(rcs, g.SetKeybinding( + FRAMEREPORTVIEW_VIEWNAME_REPORT, + gocui.KeyCtrlJ, gocui.ModNone, fr.CursorDown)) + rcs = append(rcs, g.SetKeybinding( + FRAMEREPORTVIEW_VIEWNAME_REPORT, + gocui.KeyCtrlK, gocui.ModNone, fr.CursorUp)) + rcs = append(rcs, g.SetKeybinding( + FRAMEREPORTVIEW_VIEWNAME_REPORT, + gocui.KeyCtrlD, gocui.ModNone, fr.CursorPageDown)) + rcs = append(rcs, g.SetKeybinding( + FRAMEREPORTVIEW_VIEWNAME_REPORT, + gocui.KeyCtrlU, gocui.ModNone, fr.CursorPageUp)) + rcs = append(rcs, g.SetKeybinding( + FRAMEREPORTVIEW_VIEWNAME_REPORT, + gocui.KeySpace, gocui.ModNone, fr.CursorPageDown)) + rcs = append(rcs, g.SetKeybinding( + FRAMEREPORTVIEW_VIEWNAME_REPORT, + gocui.KeyBackspace, gocui.ModNone, fr.CursorPageUp)) + rcs = append(rcs, g.SetKeybinding( + FRAMEREPORTVIEW_VIEWNAME_REPORT, + gocui.KeyBackspace2, gocui.ModNone, fr.CursorPageUp)) + // rcs = append(rcs, g.SetKeybinding( + // FRAMEREPORTVIEW_VIEWNAME_REPORT, + // gocui.KeyCtrlM, gocui.ModNone, fr.CursorMoveMiddle)) + rcs = append(rcs, g.SetKeybinding( + FRAMEREPORTVIEW_VIEWNAME_REPORT, + gocui.KeyCtrlN, gocui.ModNone, fr.NextSummary)) + rcs = append(rcs, g.SetKeybinding( + FRAMEREPORTVIEW_VIEWNAME_REPORT, + gocui.KeyCtrlP, gocui.ModNone, fr.PreSummary)) + rcs = append(rcs, g.SetKeybinding( + FRAMEREPORTVIEW_VIEWNAME_REPORT, + gocui.KeyEnter, gocui.ModNone, fr.NextView)) + for _, rc := range rcs { if rc != nil { return rc diff --git a/src/gconsole/FrameReportView.go b/src/gconsole/FrameReportView.go index 5fb3b54..f89199c 100644 --- a/src/gconsole/FrameReportView.go +++ b/src/gconsole/FrameReportView.go @@ -48,6 +48,8 @@ type ViewRact struct { Bottom int } +/////////////////////////////// +// layout ract func VIEWRACT_TARGET(maxx int, maxy int) ViewRact { return ViewRact{(-1), (-1), @@ -60,18 +62,21 @@ func VIEWRACT_VULN(maxx int, maxy int) ViewRact { maxx, int(float64(maxy)*0.3) } } -func VIEWRACT_REPORT(maxx int, maxy int) ViewRact { - return ViewRact{32, - (int(float64(maxy)*0.3)), - (int(float64(maxx - 32)*0.5)), - maxy } -} func VIEWRACT_VULNINFO(maxx int, maxy int) ViewRact { return ViewRact{32 + (int(float64(maxx - 32)*0.5)), (int(float64(maxy)*0.3)), maxx, maxy } } +func VIEWRACT_REPORT(maxx int, maxy int) ViewRact { + return ViewRact{32, + (int(float64(maxy)*0.3)), + 32 + (int(float64(maxx - 32)*0.5)), + maxy } +} +// layout ract +/////////////////////////////// + func (fr *FrameReport)SetTargetLayout(g *gocui.Gui) error { viewract := VIEWRACT_TARGET(g.Size()) @@ -147,9 +152,12 @@ func (fr *FrameReport)SetVulnInfoLayout(g *gocui.Gui) error { } func (fr *FrameReport)SetReportLayout(g *gocui.Gui) error { - maxX, maxY := g.Size() + viewract := VIEWRACT_REPORT(g.Size()) + + view, rc := g.SetView(FRAMEREPORTVIEW_VIEWNAME_REPORT, + viewract.Left, viewract.Top, + viewract.Right, viewract.Bottom); - view, rc := g.SetView(FRAMEREPORTVIEW_VIEWNAME_REPORT, 40, int(float64(maxY)*0.3), maxX, maxY) /* */ if (nil != rc) { if (gocui.ErrUnknownView != rc) { @@ -179,6 +187,8 @@ func (fr *FrameReport)NextView(g *gocui.Gui, v *gocui.View) error { case FRAMEREPORTVIEW_VIEWNAME_VULN: rc = g.SetCurrentView(FRAMEREPORTVIEW_VIEWNAME_VULNINFO) case FRAMEREPORTVIEW_VIEWNAME_VULNINFO: + rc = g.SetCurrentView(FRAMEREPORTVIEW_VIEWNAME_REPORT) + case FRAMEREPORTVIEW_VIEWNAME_REPORT: rc = g.SetCurrentView(FRAMEREPORTVIEW_VIEWNAME_TARGET) default: rc = g.SetCurrentView(FRAMEREPORTVIEW_VIEWNAME_VULN) @@ -195,11 +205,13 @@ func (fr *FrameReport)PreView(g *gocui.Gui, v *gocui.View) error { switch ( v.Name() ) { case FRAMEREPORTVIEW_VIEWNAME_TARGET: + rc = g.SetCurrentView(FRAMEREPORTVIEW_VIEWNAME_REPORT) + case FRAMEREPORTVIEW_VIEWNAME_REPORT: rc = g.SetCurrentView(FRAMEREPORTVIEW_VIEWNAME_VULNINFO) - case FRAMEREPORTVIEW_VIEWNAME_VULN: - rc = g.SetCurrentView(FRAMEREPORTVIEW_VIEWNAME_TARGET) case FRAMEREPORTVIEW_VIEWNAME_VULNINFO: rc = g.SetCurrentView(FRAMEREPORTVIEW_VIEWNAME_VULN) + case FRAMEREPORTVIEW_VIEWNAME_VULN: + rc = g.SetCurrentView(FRAMEREPORTVIEW_VIEWNAME_TARGET) default: rc = g.SetCurrentView(FRAMEREPORTVIEW_VIEWNAME_TARGET) } // switch ( v ... diff --git a/src/gconsole/gconsole.go b/src/gconsole/gconsole.go index e7daa69..f6ab255 100644 --- a/src/gconsole/gconsole.go +++ b/src/gconsole/gconsole.go @@ -75,5 +75,10 @@ func layout(g *gocui.Gui) error { return rc } // if (nil != ... + rc = G_FrameReport.SetReportLayout(g) + if (nil != rc) { + return rc + } // if (nil != ... + return nil }