summaryrefslogtreecommitdiff
path: root/buffer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'buffer.cpp')
-rw-r--r--buffer.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/buffer.cpp b/buffer.cpp
index 05bbffa..645d63c 100644
--- a/buffer.cpp
+++ b/buffer.cpp
@@ -16,6 +16,9 @@ using namespace std;
Buffer::Buffer(Manager *manager)
:manager(manager){}
+Buffer::Buffer(Manager *manager,bool singleLineMode)
+ :manager(manager),singleLineMode(singleLineMode){}
+
void Buffer::handleCommand(const Command &cmd){
//TODO: optimise the relayoutScreen's in this function
@@ -391,7 +394,7 @@ void Buffer::show(i64 atx,i64 aty,i64 width,i64 height){
static const Style textStyle={9,9,false,false};
static const Style specialStyle={5,9,false,false};
- i64 gutterWidth=numberWidth(tb.numLines())+2;
+ i64 gutterWidth=singleLineMode ? 0 : numberWidth(tb.numLines())+2;
i64 newWidth=width-gutterWidth;
if(newWidth!=lastWidth||height!=lastHeight||screen.size()==0){
if(lastWidth==-1)performInitialLayout(newWidth,height);
@@ -408,14 +411,16 @@ void Buffer::show(i64 atx,i64 aty,i64 width,i64 height){
i64 curScreenX=-1,curScreenY=-1;
// cerr<<"Buffer::show: screen.size()="<<screen.size()<<endl;
for(y=0;y<(i64)screen.size();y++){
- if(screen[y].fromx==0){
- setstyle(&gutterStyle);
- moveto(atx+gutterWidth-1-numberWidth(screen[y].line+1),aty+y);
- tprintf("%" PRIi64,screen[y].line+1);
- } else if(y==0){
- setstyle(&gutterContinuationStyle);
- moveto(atx+gutterWidth-2-numberWidth(screen[y].line+1),aty+y);
- tprintf("^%" PRIi64,screen[y].line+1);
+ if(!singleLineMode){
+ if(screen[y].fromx==0){
+ setstyle(&gutterStyle);
+ moveto(atx+gutterWidth-1-numberWidth(screen[y].line+1),aty+y);
+ tprintf("%" PRIi64,screen[y].line+1);
+ } else if(y==0){
+ setstyle(&gutterContinuationStyle);
+ moveto(atx+gutterWidth-2-numberWidth(screen[y].line+1),aty+y);
+ tprintf("^%" PRIi64,screen[y].line+1);
+ }
}
moveto(atx+gutterWidth,aty+y);
@@ -448,3 +453,7 @@ void Buffer::show(i64 atx,i64 aty,i64 width,i64 height){
moveto(curScreenX,curScreenY);
}
}
+
+string Buffer::getText() const {
+ return tb.fullText();
+}