Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Utilities
Konsole
Commits
940ceebd
Commit
940ceebd
authored
Jul 17, 2020
by
Gustavo Carneiro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move CompactHistoryBlockClass to a new file.
parent
267cc34e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
143 additions
and
73 deletions
+143
-73
src/CMakeLists.txt
src/CMakeLists.txt
+1
-0
src/CompactHistoryBlock.cpp
src/CompactHistoryBlock.cpp
+81
-0
src/CompactHistoryBlock.h
src/CompactHistoryBlock.h
+60
-0
src/History.cpp
src/History.cpp
+0
-23
src/History.h
src/History.h
+1
-50
No files found.
src/CMakeLists.txt
View file @
940ceebd
...
...
@@ -69,6 +69,7 @@ set(konsoleprivate_SRCS ${sessionadaptors_SRCS}
HistoryScrollFile.cpp
HistoryScrollNone.cpp
CharacterFormat.cpp
CompactHistoryBlock.cpp
HistorySizeDialog.cpp
widgets/HistorySizeWidget.cpp
widgets/IncrementalSearchBar.cpp
...
...
src/CompactHistoryBlock.cpp
0 → 100644
View file @
940ceebd
/*
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.
*/
// Own
#include "CompactHistoryBlock.h"
using
namespace
Konsole
;
CompactHistoryBlock
::
CompactHistoryBlock
()
:
_blockLength
(
4096
*
64
),
// 256kb
_head
(
static_cast
<
quint8
*>
(
mmap
(
nullptr
,
_blockLength
,
PROT_READ
|
PROT_WRITE
,
MAP_PRIVATE
|
MAP_ANON
,
-
1
,
0
))),
_tail
(
nullptr
),
_blockStart
(
nullptr
),
_allocCount
(
0
)
{
Q_ASSERT
(
_head
!=
MAP_FAILED
);
_tail
=
_blockStart
=
_head
;
}
CompactHistoryBlock
::~
CompactHistoryBlock
()
{
//free(_blockStart);
munmap
(
_blockStart
,
_blockLength
);
}
unsigned
int
CompactHistoryBlock
::
remaining
()
{
return
_blockStart
+
_blockLength
-
_tail
;
}
unsigned
CompactHistoryBlock
::
length
()
{
return
_blockLength
;
}
bool
CompactHistoryBlock
::
contains
(
void
*
addr
)
{
return
addr
>=
_blockStart
&&
addr
<
(
_blockStart
+
_blockLength
);
}
bool
CompactHistoryBlock
::
isInUse
()
{
return
_allocCount
!=
0
;
}
void
*
CompactHistoryBlock
::
allocate
(
size_t
size
)
{
Q_ASSERT
(
size
>
0
);
if
(
_tail
-
_blockStart
+
size
>
_blockLength
)
{
return
nullptr
;
}
void
*
block
=
_tail
;
_tail
+=
size
;
////qDebug() << "allocated " << length << " bytes at address " << block;
_allocCount
++
;
return
block
;
}
void
CompactHistoryBlock
::
deallocate
()
{
_allocCount
--
;
Q_ASSERT
(
_allocCount
>=
0
);
}
src/CompactHistoryBlock.h
0 → 100644
View file @
940ceebd
/*
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 COMPACTHISTORYBLOCK_H
#define COMPACTHISTORYBLOCK_H
// Konsole
#include "Character.h"
// System
#include <sys/mman.h>
namespace
Konsole
{
class
CompactHistoryBlock
{
public:
CompactHistoryBlock
();
virtual
~
CompactHistoryBlock
();
virtual
unsigned
int
remaining
();
virtual
unsigned
length
();
virtual
void
*
allocate
(
size_t
size
);
virtual
bool
contains
(
void
*
addr
);
virtual
void
deallocate
();
virtual
bool
isInUse
();
private:
size_t
_blockLength
;
quint8
*
_head
;
quint8
*
_tail
;
quint8
*
_blockStart
;
int
_allocCount
;
};
}
#endif
src/History.cpp
View file @
940ceebd
...
...
@@ -60,29 +60,6 @@ using namespace Konsole;
at constant costs.
*/
////////////////////////////////////////////////////////////////
// Compact History Scroll //////////////////////////////////////
////////////////////////////////////////////////////////////////
void
*
CompactHistoryBlock
::
allocate
(
size_t
size
)
{
Q_ASSERT
(
size
>
0
);
if
(
_tail
-
_blockStart
+
size
>
_blockLength
)
{
return
nullptr
;
}
void
*
block
=
_tail
;
_tail
+=
size
;
////qDebug() << "allocated " << length << " bytes at address " << block;
_allocCount
++
;
return
block
;
}
void
CompactHistoryBlock
::
deallocate
()
{
_allocCount
--
;
Q_ASSERT
(
_allocCount
>=
0
);
}
void
*
CompactHistoryBlockList
::
allocate
(
size_t
size
)
{
CompactHistoryBlock
*
block
;
...
...
src/History.h
View file @
940ceebd
...
...
@@ -37,6 +37,7 @@
#include "HistoryScrollFile.h"
#include "HistoryScrollNone.h"
#include "CharacterFormat.h"
#include "CompactHistoryBlock.h"
// Konsole
#include "Character.h"
...
...
@@ -50,56 +51,6 @@ namespace Konsole {
//////////////////////////////////////////////////////////////////////
typedef
QVector
<
Character
>
TextLine
;
class
CompactHistoryBlock
{
public:
CompactHistoryBlock
()
:
_blockLength
(
4096
*
64
),
// 256kb
_head
(
static_cast
<
quint8
*>
(
mmap
(
nullptr
,
_blockLength
,
PROT_READ
|
PROT_WRITE
,
MAP_PRIVATE
|
MAP_ANON
,
-
1
,
0
))),
_tail
(
nullptr
),
_blockStart
(
nullptr
),
_allocCount
(
0
)
{
Q_ASSERT
(
_head
!=
MAP_FAILED
);
_tail
=
_blockStart
=
_head
;
}
virtual
~
CompactHistoryBlock
()
{
//free(_blockStart);
munmap
(
_blockStart
,
_blockLength
);
}
virtual
unsigned
int
remaining
()
{
return
_blockStart
+
_blockLength
-
_tail
;
}
virtual
unsigned
length
()
{
return
_blockLength
;
}
virtual
void
*
allocate
(
size_t
size
);
virtual
bool
contains
(
void
*
addr
)
{
return
addr
>=
_blockStart
&&
addr
<
(
_blockStart
+
_blockLength
);
}
virtual
void
deallocate
();
virtual
bool
isInUse
()
{
return
_allocCount
!=
0
;
}
private:
size_t
_blockLength
;
quint8
*
_head
;
quint8
*
_tail
;
quint8
*
_blockStart
;
int
_allocCount
;
};
class
CompactHistoryBlockList
{
public:
...
...
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