Culling text outside of a certain bounds?

I’m making a scrolling textbox(much like an HTML textarea) in a processing project, but when the box is full and has nowhere to overflow, it bleeds into other elements. is there any way to make the text only appear within the bounds of the background rectangle, without just using visual tricks(black text on black background within white box)?

Can you share the part of the code you have or screenshots? Are you using p5.js or Processing? Your textbox is drawn using text()?

Maybe you can use:

text(str, x1, y1, x2, y2)

x1 float: by default, the x-coordinate of text […]
y1 float: by default, the y-coordinate of text […]
x2 float: by default, the width of the text box […]
y2 float: by default, the height of the text box […]

Or maybe you could draw your text on a PGraphics and hide the part that is outside the box with another PGraphics and mask(), maybe this way.

I’m using processing 3(java) and am making my own gui system, however this is a tad too complex(it has 15 pages of intertwined classes) here is my full code as a zip file from my website:
https://jakesandbox.com/tbinput.zip