Diffstat (limited to 'core/apps/embeddedkonsole/TEHistory.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/apps/embeddedkonsole/TEHistory.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/apps/embeddedkonsole/TEHistory.cpp b/core/apps/embeddedkonsole/TEHistory.cpp index 504cd13..2417af1 100644 --- a/core/apps/embeddedkonsole/TEHistory.cpp +++ b/core/apps/embeddedkonsole/TEHistory.cpp | |||
@@ -45,97 +45,97 @@ | |||
45 | */ | 45 | */ |
46 | 46 | ||
47 | 47 | ||
48 | HistoryScroll::HistoryScroll() | 48 | HistoryScroll::HistoryScroll() |
49 | { | 49 | { |
50 | m_lines = NULL; | 50 | m_lines = NULL; |
51 | m_max_lines = 0; | 51 | m_max_lines = 0; |
52 | m_cells = NULL; | 52 | m_cells = NULL; |
53 | m_max_cells = 0; | 53 | m_max_cells = 0; |
54 | m_num_lines = 0; | 54 | m_num_lines = 0; |
55 | m_first_line = 0; | 55 | m_first_line = 0; |
56 | m_last_cell = 0; | 56 | m_last_cell = 0; |
57 | m_start_line = 0; | 57 | m_start_line = 0; |
58 | } | 58 | } |
59 | 59 | ||
60 | HistoryScroll::~HistoryScroll() | 60 | HistoryScroll::~HistoryScroll() |
61 | { | 61 | { |
62 | setSize(0,0); | 62 | setSize(0,0); |
63 | } | 63 | } |
64 | 64 | ||
65 | void HistoryScroll::setSize(int lines, int cells) | 65 | void HistoryScroll::setSize(int lines, int cells) |
66 | { | 66 | { |
67 | // could try to preserve the existing data... | 67 | // could try to preserve the existing data... |
68 | // printf("setSize(%d,%d)\n", lines, cells); | 68 | // printf("setSize(%d,%d)\n", lines, cells); |
69 | if (m_lines) { | 69 | if (m_lines) { |
70 | delete m_lines; | 70 | delete m_lines; |
71 | m_lines = NULL; | 71 | m_lines = NULL; |
72 | } | 72 | } |
73 | if (m_cells) { | 73 | if (m_cells) { |
74 | delete m_cells; | 74 | delete m_cells; |
75 | m_cells = NULL; | 75 | m_cells = NULL; |
76 | } | 76 | } |
77 | m_max_lines = m_max_cells = 0; | 77 | m_max_lines = m_max_cells = 0; |
78 | if (lines > 0 && cells > 0) { | 78 | if (lines > 0 && cells > 0) { |
79 | m_max_lines = lines; | 79 | m_max_lines = lines; |
80 | m_lines = new int[m_max_lines]; | 80 | m_lines = new int[m_max_lines]; |
81 | m_lines[0] = 0; | 81 | m_lines[0] = 0; |
82 | m_max_cells = cells; | 82 | m_max_cells = cells; |
83 | m_cells = new ca[m_max_cells]; | 83 | m_cells = new ca[m_max_cells]; |
84 | } | 84 | } |
85 | m_first_line = 0; | 85 | m_first_line = 0; |
86 | m_num_lines = 0; | 86 | m_num_lines = 0; |
87 | m_last_cell = 0; | 87 | m_last_cell = 0; |
88 | m_start_line = 0; | 88 | m_start_line = 0; |
89 | } | 89 | } |
90 | 90 | ||
91 | void HistoryScroll::setScroll(bool on) | 91 | void HistoryScroll::setScroll(bool on) |
92 | { | 92 | { |
93 | Config cfg("Qkonsole"); | 93 | Config cfg( "Konsole" ); |
94 | cfg.setGroup("History"); | 94 | cfg.setGroup("History"); |
95 | // printf("setScroll(%d)\n", on); | 95 | // printf("setScroll(%d)\n", on); |
96 | if (on) { | 96 | if (on) { |
97 | int lines = cfg.readNumEntry("history_lines",300); | 97 | int lines = cfg.readNumEntry("history_lines",300); |
98 | int avg_line = cfg.readNumEntry("avg_line_length",60); | 98 | int avg_line = cfg.readNumEntry("avg_line_length",60); |
99 | int cells = lines * avg_line; | 99 | int cells = lines * avg_line; |
100 | setSize(lines,cells); | 100 | setSize(lines,cells); |
101 | } else { | 101 | } else { |
102 | setSize(0,0); | 102 | setSize(0,0); |
103 | } | 103 | } |
104 | } | 104 | } |
105 | 105 | ||
106 | bool HistoryScroll::hasScroll() | 106 | bool HistoryScroll::hasScroll() |
107 | { | 107 | { |
108 | return (m_max_lines > 0); | 108 | return (m_max_lines > 0); |
109 | } | 109 | } |
110 | 110 | ||
111 | int HistoryScroll::getLines() | 111 | int HistoryScroll::getLines() |
112 | { | 112 | { |
113 | return(m_num_lines); | 113 | return(m_num_lines); |
114 | } | 114 | } |
115 | 115 | ||
116 | int HistoryScroll::getLineLen(int lineno) | 116 | int HistoryScroll::getLineLen(int lineno) |
117 | { | 117 | { |
118 | if (!hasScroll()) return 0; | 118 | if (!hasScroll()) return 0; |
119 | if (lineno >= m_num_lines) { | 119 | if (lineno >= m_num_lines) { |
120 | // printf("getLineLen(%d) out of range %d\n", lineno, m_num_lines); | 120 | // printf("getLineLen(%d) out of range %d\n", lineno, m_num_lines); |
121 | return(0); | 121 | return(0); |
122 | } | 122 | } |
123 | int len = startOfLine(lineno+1) - startOfLine(lineno); | 123 | int len = startOfLine(lineno+1) - startOfLine(lineno); |
124 | if (len < 0) { | 124 | if (len < 0) { |
125 | len += m_max_cells; | 125 | len += m_max_cells; |
126 | } | 126 | } |
127 | // printf("getLineLen(%d) = %d\n", lineno, len); | 127 | // printf("getLineLen(%d) = %d\n", lineno, len); |
128 | return(len); | 128 | return(len); |
129 | } | 129 | } |
130 | 130 | ||
131 | int HistoryScroll::startOfLine(int lineno) | 131 | int HistoryScroll::startOfLine(int lineno) |
132 | { | 132 | { |
133 | // printf("startOfLine(%d) =", lineno); | 133 | // printf("startOfLine(%d) =", lineno); |
134 | if (!hasScroll()) return 0; | 134 | if (!hasScroll()) return 0; |
135 | assert(lineno >= 0 && lineno <= m_num_lines); | 135 | assert(lineno >= 0 && lineno <= m_num_lines); |
136 | if (lineno < m_num_lines) { | 136 | if (lineno < m_num_lines) { |
137 | int index = lineno + m_first_line; | 137 | int index = lineno + m_first_line; |
138 | if (index >= m_max_lines) | 138 | if (index >= m_max_lines) |
139 | index -= m_max_lines; | 139 | index -= m_max_lines; |
140 | // printf("%d\n", m_lines[index]); | 140 | // printf("%d\n", m_lines[index]); |
141 | return(m_lines[index]); | 141 | return(m_lines[index]); |