Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Adding GUI query option to output results as plain text#79

Open
HarshalAtre wants to merge 5 commits into
dspinellis:masterfrom
HarshalAtre:feat/gui-query-option
Open

Adding GUI query option to output results as plain text#79
HarshalAtre wants to merge 5 commits into
dspinellis:masterfrom
HarshalAtre:feat/gui-query-option

Conversation

@HarshalAtre
Copy link
Copy Markdown
Contributor

@HarshalAtre HarshalAtre commented Feb 24, 2026

Description

This PR adds a per-query "Plain text output" checkbox to CScout's web interface query forms, allowing users to request plain text results for individual queries instead of HTML. This is useful for machine consumption, scripting, or users who prefer unformatted output.

Related issue: #35


Changes

  • Added a "Plain text output" checkbox next to the query title field on all three query forms (files, identifiers, functions)
  • Plain text mode is activated per-query via the txt checkbox (bool plain_text = !!swill_getvar("txt"))
  • Unified all three output functions into a single loop with if (plain_text) branches, eliminating duplicated code blocks
  • Configured the pager as a no-operation (INT_MAX page size) in plain text mode, since paging is not appropriate for machine-consumable output
  • Added output_plain_text_element template specializations for type-safe plain text output of identifiers, functions, and file paths
  • Function metrics plain text output uses tab-separated format (TSV): Function Name\tMetricName\n...
  • Removed meaningless "Original HTML output" comment

Verification

  • Default behavior (HTML output) is unchanged when the checkbox is not checked
  • Plain text mode produces clean, unformatted output for all three query types (files, identifiers, functions)
  • No errors reported by compiler/linter

Examples

Before (HTML)

<a href="id.html?id=0x12345">identifier_name</a><br>

After (Plain Text)

identifier_name

@HarshalAtre
Copy link
Copy Markdown
Contributor Author

@dspinellis Please review

Copy link
Copy Markdown
Owner

@dspinellis dspinellis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the whitespace fixes. I now see some required code structure improvements. I made comments to the first case, but they apply to all.

Comment thread src/cscout.cpp Outdated
Comment thread src/cscout.cpp Outdated
Comment thread src/cscout.cpp Outdated
@HarshalAtre HarshalAtre force-pushed the feat/gui-query-option branch 2 times, most recently from f80f967 to 98a0634 Compare March 2, 2026 00:48
@HarshalAtre
Copy link
Copy Markdown
Contributor Author

Thank you for the whitespace fixes. I now see some required code structure improvements. I made comments to the first case, but they apply to all.

Addressed all comments

@dspinellis , Sir please re-review

@HarshalAtre
Copy link
Copy Markdown
Contributor Author

Hey @dspinellis , Just a reminder

Copy link
Copy Markdown
Owner

@dspinellis dspinellis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code shows me that you removed the pagination info. This means that code cannot reliably go through the results as you want. Consider adding a URL option (no user option is required) for providing the results in JSON with suitable pagination options and results.

Comment thread src/cscout.cpp Outdated
@HarshalAtre HarshalAtre force-pushed the feat/gui-query-option branch from 98a0634 to 1619545 Compare March 17, 2026 13:37
@HarshalAtre
Copy link
Copy Markdown
Contributor Author

HarshalAtre commented Mar 17, 2026

The code shows me that you removed the pagination info. This means that code cannot reliably go through the results as you want. Consider adding a URL option (no user option is required) for providing the results in JSON with suitable pagination options and results.

The code shows me that you removed the pagination info. This means that code cannot reliably go through the results as you want. Consider adding a URL option (no user option is required) for providing the results in JSON with suitable pagination options and results.

@dspinellis , Addresed:

  • JSON output mode with pagination and navigation links is implemented for all query result paths.
  • The negated plain_text conditional is now reversed to positive form.
  • Code builds cleanly and matches the requested structure.

@HarshalAtre HarshalAtre requested a review from dspinellis March 17, 2026 13:46
@HarshalAtre
Copy link
Copy Markdown
Contributor Author

@dspinellis , just a reminder

Copy link
Copy Markdown
Owner

@dspinellis dspinellis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! The functionality looks right, but the code volume has increased substantially with many repetitions. Please consider abstracting output based on text type and pagination into separate files so that the original code can be considerably cleaner.

@HarshalAtre
Copy link
Copy Markdown
Contributor Author

HarshalAtre commented Apr 21, 2026

Thank you! The functionality looks right, but the code volume has increased substantially with many repetitions. Please consider abstracting output based on text type and pagination into separate files so that the original code can be considerably cleaner.

@dspinellis , Addressed

@HarshalAtre HarshalAtre requested a review from dspinellis April 21, 2026 23:00
@HarshalAtre HarshalAtre force-pushed the feat/gui-query-option branch from a39dee8 to d414ba9 Compare April 21, 2026 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants