Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Konsole
Commits
44c4ed5d
Commit
44c4ed5d
authored
Jul 15, 2020
by
Gustavo Carneiro
Browse files
Move HistoryScrollFile class to a new file.
parent
e90fd2c9
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/CMakeLists.txt
View file @
44c4ed5d
...
...
@@ -66,6 +66,7 @@ set(konsoleprivate_SRCS ${sessionadaptors_SRCS}
History.cpp
HistoryFile.cpp
HistoryScroll.cpp
HistoryScrollFile.cpp
HistorySizeDialog.cpp
widgets/HistorySizeWidget.cpp
widgets/IncrementalSearchBar.cpp
...
...
src/History.cpp
View file @
44c4ed5d
...
...
@@ -21,6 +21,8 @@
// Own
#include "History.h"
#include "HistoryScrollFile.h"
#include "konsoledebug.h"
#include "KonsoleSettings.h"
...
...
@@ -58,78 +60,6 @@ using namespace Konsole;
at constant costs.
*/
// History Scroll File //////////////////////////////////////
/*
The history scroll makes a Row(Row(Cell)) from
two history buffers. The index buffer contains
start of line positions which refer to the cells
buffer.
Note that index[0] addresses the second line
(line #1), while the first line (line #0) starts
at 0 in cells.
*/
HistoryScrollFile
::
HistoryScrollFile
()
:
HistoryScroll
(
new
HistoryTypeFile
())
{
}
HistoryScrollFile
::~
HistoryScrollFile
()
=
default
;
int
HistoryScrollFile
::
getLines
()
{
return
_index
.
len
()
/
sizeof
(
qint64
);
}
int
HistoryScrollFile
::
getLineLen
(
int
lineno
)
{
return
(
startOfLine
(
lineno
+
1
)
-
startOfLine
(
lineno
))
/
sizeof
(
Character
);
}
bool
HistoryScrollFile
::
isWrappedLine
(
int
lineno
)
{
if
(
lineno
>=
0
&&
lineno
<=
getLines
())
{
unsigned
char
flag
=
0
;
_lineflags
.
get
(
reinterpret_cast
<
char
*>
(
&
flag
),
sizeof
(
unsigned
char
),
(
lineno
)
*
sizeof
(
unsigned
char
));
return
flag
!=
0U
;
}
return
false
;
}
qint64
HistoryScrollFile
::
startOfLine
(
int
lineno
)
{
if
(
lineno
<=
0
)
{
return
0
;
}
if
(
lineno
<=
getLines
())
{
qint64
res
=
0
;
_index
.
get
(
reinterpret_cast
<
char
*>
(
&
res
),
sizeof
(
qint64
),
(
lineno
-
1
)
*
sizeof
(
qint64
));
return
res
;
}
return
_cells
.
len
();
}
void
HistoryScrollFile
::
getCells
(
int
lineno
,
int
colno
,
int
count
,
Character
res
[])
{
_cells
.
get
(
reinterpret_cast
<
char
*>
(
res
),
count
*
sizeof
(
Character
),
startOfLine
(
lineno
)
+
colno
*
sizeof
(
Character
));
}
void
HistoryScrollFile
::
addCells
(
const
Character
text
[],
int
count
)
{
_cells
.
add
(
reinterpret_cast
<
const
char
*>
(
text
),
count
*
sizeof
(
Character
));
}
void
HistoryScrollFile
::
addLine
(
bool
previousWrapped
)
{
qint64
locn
=
_cells
.
len
();
_index
.
add
(
reinterpret_cast
<
char
*>
(
&
locn
),
sizeof
(
qint64
));
unsigned
char
flags
=
previousWrapped
?
0x01
:
0x00
;
_lineflags
.
add
(
reinterpret_cast
<
char
*>
(
&
flags
),
sizeof
(
char
));
}
// History Scroll None //////////////////////////////////////
HistoryScrollNone
::
HistoryScrollNone
()
:
...
...
src/History.h
View file @
44c4ed5d
...
...
@@ -40,32 +40,6 @@
namespace
Konsole
{
//////////////////////////////////////////////////////////////////////
// File-based history (e.g. file log, no limitation in length)
//////////////////////////////////////////////////////////////////////
class
KONSOLEPRIVATE_EXPORT
HistoryScrollFile
:
public
HistoryScroll
{
public:
explicit
HistoryScrollFile
();
~
HistoryScrollFile
()
override
;
int
getLines
()
override
;
int
getLineLen
(
int
lineno
)
override
;
void
getCells
(
int
lineno
,
int
colno
,
int
count
,
Character
res
[])
override
;
bool
isWrappedLine
(
int
lineno
)
override
;
void
addCells
(
const
Character
text
[],
int
count
)
override
;
void
addLine
(
bool
previousWrapped
=
false
)
override
;
private:
qint64
startOfLine
(
int
lineno
);
HistoryFile
_index
;
// lines Row(qint64)
HistoryFile
_cells
;
// text Row(Character)
HistoryFile
_lineflags
;
// flags Row(unsigned char)
};
//////////////////////////////////////////////////////////////////////
// Nothing-based history (no history :-)
//////////////////////////////////////////////////////////////////////
...
...
src/HistoryScrollFile.cpp
0 → 100644
View file @
44c4ed5d
/*
This file is part of Konsole, an X terminal.
Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
*/
#include "History.h"
#include "HistoryScrollFile.h"
/*
The history scroll makes a Row(Row(Cell)) from
two history buffers. The index buffer contains
start of line positions which refer to the cells
buffer.
Note that index[0] addresses the second line
(line #1), while the first line (line #0) starts
at 0 in cells.
*/
using
namespace
Konsole
;
HistoryScrollFile
::
HistoryScrollFile
()
:
HistoryScroll
(
new
HistoryTypeFile
())
{
}
HistoryScrollFile
::~
HistoryScrollFile
()
=
default
;
int
HistoryScrollFile
::
getLines
()
{
return
_index
.
len
()
/
sizeof
(
qint64
);
}
int
HistoryScrollFile
::
getLineLen
(
int
lineno
)
{
return
(
startOfLine
(
lineno
+
1
)
-
startOfLine
(
lineno
))
/
sizeof
(
Character
);
}
bool
HistoryScrollFile
::
isWrappedLine
(
int
lineno
)
{
if
(
lineno
>=
0
&&
lineno
<=
getLines
())
{
unsigned
char
flag
=
0
;
_lineflags
.
get
(
reinterpret_cast
<
char
*>
(
&
flag
),
sizeof
(
unsigned
char
),
(
lineno
)
*
sizeof
(
unsigned
char
));
return
flag
!=
0u
;
}
return
false
;
}
qint64
HistoryScrollFile
::
startOfLine
(
int
lineno
)
{
if
(
lineno
<=
0
)
{
return
0
;
}
if
(
lineno
<=
getLines
())
{
qint64
res
=
0
;
_index
.
get
(
reinterpret_cast
<
char
*>
(
&
res
),
sizeof
(
qint64
),
(
lineno
-
1
)
*
sizeof
(
qint64
));
return
res
;
}
return
_cells
.
len
();
}
void
HistoryScrollFile
::
getCells
(
int
lineno
,
int
colno
,
int
count
,
Character
res
[])
{
_cells
.
get
(
reinterpret_cast
<
char
*>
(
res
),
count
*
sizeof
(
Character
),
startOfLine
(
lineno
)
+
colno
*
sizeof
(
Character
));
}
void
HistoryScrollFile
::
addCells
(
const
Character
text
[],
int
count
)
{
_cells
.
add
(
reinterpret_cast
<
const
char
*>
(
text
),
count
*
sizeof
(
Character
));
}
void
HistoryScrollFile
::
addLine
(
bool
previousWrapped
)
{
qint64
locn
=
_cells
.
len
();
_index
.
add
(
reinterpret_cast
<
char
*>
(
&
locn
),
sizeof
(
qint64
));
unsigned
char
flags
=
previousWrapped
?
0x01
:
0x00
;
_lineflags
.
add
(
reinterpret_cast
<
char
*>
(
&
flags
),
sizeof
(
char
));
}
src/HistoryScrollFile.h
0 → 100644
View file @
44c4ed5d
/*
This file is part of Konsole, an X terminal.
Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
*/
#ifndef HISTORYSCROLLFILE_H
#define HISTORYSCROLLFILE_H
#include "konsoleprivate_export.h"
// History
#include "HistoryFile.h"
#include "HistoryScroll.h"
namespace
Konsole
{
//////////////////////////////////////////////////////////////////////
// File-based history (e.g. file log, no limitation in length)
//////////////////////////////////////////////////////////////////////
class
KONSOLEPRIVATE_EXPORT
HistoryScrollFile
:
public
HistoryScroll
{
public:
explicit
HistoryScrollFile
();
~
HistoryScrollFile
()
override
;
int
getLines
()
override
;
int
getLineLen
(
int
lineno
)
override
;
void
getCells
(
int
lineno
,
int
colno
,
int
count
,
Character
res
[])
override
;
bool
isWrappedLine
(
int
lineno
)
override
;
void
addCells
(
const
Character
text
[],
int
count
)
override
;
void
addLine
(
bool
previousWrapped
=
false
)
override
;
private:
qint64
startOfLine
(
int
lineno
);
HistoryFile
_index
;
// lines Row(qint64)
HistoryFile
_cells
;
// text Row(Character)
HistoryFile
_lineflags
;
// flags Row(unsigned char)
};
}
#endif
src/autotests/HistoryTest.cpp
View file @
44c4ed5d
...
...
@@ -26,6 +26,7 @@
#include "../session/Session.h"
#include "../Emulation.h"
#include "../History.h"
#include "../HistoryScrollFile.h"
using
namespace
Konsole
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment