Comments (3)
@samizdatco That's right, it doesn't support transparency directly.
The purpose of TextBuffer is to manage the text like in a text editor.
It's way more handy than using the ScreenBuffer's low level .put()
method.
Moreover, the TextBuffer has a virtually infinite size by default, a thing that is not possible with the more concrete ScreenBuffer.
But things like transparency and composition are ScreenBuffer's job.
In fact, the TextBuffer content is just copied as it is (geometry aware) to the ScreenBuffer.
So the transparency flags are written into the ScreenBuffer instead of being applied.
In your example, if you want to achieve what you want, you need one extra ScreenBuffer.
In fact there should always be a ScreenBuffer backer for each TextBuffer, but you can eventully mutualize them if they do not overlap.
In your example the ScreenBuffer used as the backer has overlapping informations (the one below the TextBuffer).
from terminal-kit.
@samizdatco This is your modified example:
function useTextBuffer(){
// place a textbuffer in the middle of the destination
// screenbuffer and set its empty cells to be
// transparent for bg and char
foreground = termkit.ScreenBuffer.create({
dst:background,
x:10,
y:8,
width:20,
height:3
})
textbuffer = termkit.TextBuffer.create({
dst:foreground,
x:0,
y:0,
width:20,
height:3
})
textbuffer.setEmptyCellAttr({
bgTransparency:true,
charTransparency:true
})
// the message text should be visible, but the surrounding
// rows and cols of the TextBuffer should(?) be transparent
textbuffer.moveTo(2,1)
textbuffer.insert('hello textbuffer', { bgColor: 'blue' } )
textbuffer.draw()
}
function useScreenBuffer(){
// place a child screenbuffer in the middle of the
// parent screenbuffer and draw a similar message
foreground = termkit.ScreenBuffer.create({
dst:background,
x:10,
y:8,
width:20,
height:3
})
foreground.put({x:1, y:1}, 'hello screenbuffer')
}
var termkit = require( 'terminal-kit' ),
term = termkit.terminal,
textbuffer, foreground, background;
// set up the base ScreenBuffer and add one of our two
// child buffers to it then draw everything to the term
background = termkit.ScreenBuffer.create({
dst:term,
x:1,
y:1,
width:40,
height:20,
noFill:true
})
background.fill({
char:'ยท',
attr:{color:'white', bgColor:'brightBlue'}
})
useTextBuffer() // or useScreenBuffer()
term.clear()
foreground.draw({blending:true})
background.draw()
Note how there are one more buffer in the .useTextBuffer()
method.
Also note that you should give the attr when inserting (.insert()
) or it will default to the emptyCellAttr.
from terminal-kit.
Thanks for explaining. That clears things up considerably.
from terminal-kit.
Related Issues (20)
- Document model - typed? dev branch?
- terminalkit.TextBox is not a constructor HOT 3
- document: InlineInputField only widthPercent breaks input
- Redraw window every "frame" HOT 1
- Word/Line wrap ERROR when x,y,width or height of TextBox are non integers
- Unable to draw the correct image in vscode dark-mode terminal!
- Can't run after packed with pkg HOT 3
- Cannot input after using term.inputField() HOT 4
- Issue: Terminal stuck in while-loop when initating another terminal with stdin/stdout
- Form control event and validation
- form render issue - hide/show control
- Erase Everything - How? HOT 1
- Possible EventEmitter memory leak
- Multiple Documents in Same Terminal Screen
- support for fonts HOT 1
- term.table does not work in Azure pipeline HOT 6
- term.table does not work in Azure pipeline HOT 1
- Unable to bundle code with dependencies HOT 5
- inputField Inline support? HOT 1
- Documentation request: cannot chain .inputField
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from terminal-kit.