Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rolling context buffer for backward context #106

Open
yoavnir opened this issue Oct 23, 2019 · 2 comments
Open

Rolling context buffer for backward context #106

yoavnir opened this issue Oct 23, 2019 · 2 comments
Labels
enhancement New feature or request Future Enhancement or fix for a future version good first issue Good for newcomers help wanted Extra attention is needed

Comments

@yoavnir
Copy link
Owner

yoavnir commented Oct 23, 2019

Used similar to WRITE:

  • CTXBUF + numeric constant indicating count of backwards lines
  • DUMPCTX - causes an emptying of the buffer
  • SETCTR + numeric constant indicating count of forward lines
  • settablectr() function - decremented with each line. Starts at zero and decreases with every line

Example:

# Print 3 lines before and 5 lines after any line that contains 'marker'
1-* 1
if "includes(@@,'marker')" then
    DUMPCTX # dumps the queue
    SETCTR   5
endif
if "settablectr()<=0" then
    CTXBUF  3  # eats the record into a size-3 queue. Otherwise it gets printed
endif
@yoavnir yoavnir added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers Future Enhancement or fix for a future version labels Oct 23, 2019
@yoavnir
Copy link
Owner Author

yoavnir commented Oct 23, 2019

I don't like the names. This needs some more thought.

@yoavnir
Copy link
Owner Author

yoavnir commented Oct 23, 2019

How about:

  • a new CONTEXT keyword that can be used in several ways:
    • CONTEXT ON causes the writes to go to a rotating buffer.
    • CONTEXT OFF causes the writes to go to the output.
    • CONTEXT DUMP 3,7 causes the previous 3 lines and following 7 lines to go to output. The rest of the rotating context buffer is cleared.
    • CONTEXT PREFIX expression - causes a line containing the result of the evaluated expression to be printed before the context dump
    • CONTEXT SUFFIX expression - causes a line containing the result of the evaluated expression to be printed after the context dump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Future Enhancement or fix for a future version good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant