summaryrefslogtreecommitdiffstats
path: root/Meter.c
Commit message (Collapse)AuthorAgeFilesLines
* Introduce METER_BUFFER_CHECK and METER_BUFFER_APPEND_CHR to cleanup writing ↵Christian Göttsche2020-12-061-5/+5
| | | | | | to bar buffers Closes: #294
* Use size_t as len type for Meter_UpdateValuesChristian Göttsche2020-12-061-3/+2
| | | | Most of the time the parameter is passed to snprintf type functions
* IWYU updateChristian Göttsche2020-12-061-0/+1
|
* Meter: fix bar coloring without wide ncurses supportChristian Göttsche2020-12-051-6/+5
| | | | attrset() seems to not work with mvaddchnstr()
* Resolve conversion from int to charChristian Göttsche2020-12-051-1/+1
|
* Resolve conversion from int to unsigned and backChristian Göttsche2020-12-051-5/+2
|
* Update even more snprintfsChristian Göttsche2020-11-281-6/+6
| | | | Use size of actual buffers instead of magic numbers
* Add support to change numeric options in settings screenChristian Göttsche2020-11-251-1/+2
| | | | Like delay or highlightDelaySecs
* Fully support non-ascii characters in Meter-BarChristian Göttsche2020-11-251-8/+17
| | | | | | | | | | Currently the code does not handle multi-byte characters, so length- computations take the raw count of C characters and not the to displayed size into account. An example is the degree sign for temperatures. Closes: #329
* Embracing branchesBenny Baumann2020-11-021-9/+20
|
* Spacing around operatorsBenny Baumann2020-11-021-18/+18
|
* Spacing after keywords (for)Benny Baumann2020-11-021-1/+1
|
* Use integer type for item count instead of charChristian Göttsche2020-10-311-5/+3
|
* Hold only a const version of the ProcessList in MetersChristian Göttsche2020-10-261-1/+1
|
* Assert allocating non-zero size memoryChristian Göttsche2020-10-191-1/+1
| | | | | | | | Allocating zero size memory results in implementation-defined behavior: man:malloc(3) : If size is 0, then malloc() returns either NULL, or a unique pointer value that can later be successfully passed to free().
* Make all required includes explicitBenny Baumann2020-10-181-8/+12
| | | | Information as seen by IWYU 0.12 + clang 9 on Linux
* Rename StringUtils.[ch] to XUtils.[ch]Benny Baumann2020-10-161-1/+1
|
* Meter: use explicit type for drawDataChristian Göttsche2020-10-121-1/+1
|
* Mark Object pointer to _display function constChristian Göttsche2020-10-101-3/+2
|
* Mark Object instances constChristian Göttsche2020-10-071-4/+4
|
* Mark Object classes and Object class fields constChristian Göttsche2020-10-071-4/+4
|
* Update License consistently to GPLv2 as per COPYING fileDaniel Lange2020-10-051-1/+1
|
* Covert Meter attributes to file-local constant arraysChristian Göttsche2020-09-291-1/+1
|
* Drop redundant casts to the same typeChristian Göttsche2020-09-291-1/+1
|
* Drop unused macrosChristian Göttsche2020-09-241-2/+0
|
* Clean up some code duplication in the header filesHugo Musso Gualandi2020-09-121-4/+0
| | | | | | | | | | | | | PR htop-dev/htop#70 got rid of the infrastructure for generating header files, but it left behind some code duplication. Some of cases are things that belong in the header file and don't need to be repeated in the C file. Other cases are things that belong in the C file and don't need to be in the header file. In this commit I tried to fix all of these that I could find. When given a choice I preferred keeping things out of the header file, unless they were being used by someone else.
* Consolidate repeated macro definitions into one headerNathan Scott2020-09-091-11/+0
| | | | | | | | The MIN, MAX, CLAMP, MINIMUM, and MAXIMUM macros appear throughout the codebase with many re-definitions. Make a single copy of each in a common header file, and use the BSD variants of MINIMUM/MAXIMUM due to conflicts in the system <sys/param.h> headers.
* Axe automated header generation.Zev Weiss2020-09-031-83/+0
| | | | | | | | | | | | | | Reasoning: - implementation was unsound -- broke down when I added a fairly basic macro definition expanding to a struct initializer in a *.c file. - made it way too easy (e.g. via otherwise totally innocuous git commands) to end up with timestamps such that it always ran MakeHeader.py but never used its output, leading to overbuild noise when running what should be a null 'make'. - but mostly: it's just an awkward way of dealing with C code.
* Merge branch 'hishamhm-pull-960'Nathan Scott2020-08-201-8/+8
|\
| * Clean up existing whitespaceDaniel Flanagan2019-10-311-8/+8
| |
* | fixed display of blank barsJonischkeit Clemens2020-08-181-0/+3
|/ | | | | The buffer for blank bars was left uninitialized resulting in random looking characters sometimes even overwriting the end of the bar.
* Fix out-of-bounds readHisham Muhammad2018-02-181-1/+1
| | | | | Detected by Coverity: https://scan8.coverity.com/reports.htm#v13252/p10402/fileInstanceId=22093847&defectInstanceId=7543344&mergedDefectId=174181
* Fix indentationHisham Muhammad2018-02-181-1/+1
|
* Fix issue with small terminals.Hisham Muhammad2018-02-131-1/+1
| | | | Fixes #733.
* Clarify we are looking for the null terminationcoypoop2018-02-041-1/+1
| | | Not for a comparison to zero
* Security review: check results of snprintf.Hisham Muhammad2017-07-271-4/+4
| | | | | Calls marked with xSnprintf shouldn't fail. Abort program cleanly if any of them does.
* Merge pull request #651 from Explorer09/graph-mode-drawHisham Muhammad2017-07-261-2/+2
|\ | | | | Round values in graph drawing (instead of implicit truncate)
| * Round values in graph drawing (instead of implicit truncate)Explorer092017-07-151-2/+2
| |
* | Mark some things as constRichard2017-07-221-6/+6
|/ | | | | | | Several string pointer arrays pointed to const strings but were not const themselves. A few various structures and arrays were also marked const.
* Let BarMeterMode_characters[] be const array.Explorer092016-07-221-1/+1
|
* Remove redundant is-null checks on free(Meter.drawData)Explorer092016-05-271-4/+2
|
* Rename Meter.setValues() functions to updateValues()Explorer092016-05-041-9/+10
| | | | | | | | | | | | Rationale (copied from htop issue #471): The function name "setValues" is misleading. For most OOP (object- oriented programming) contexts, setXXX functions mean they will change some member variables of an object into something specified in function arguments. But in the *Meter_setValues() case, the new values are not from the arguments, but from a hard-coded source. The caller is not supposed to change the values[] to anything it likes, but rather to "update" the values from the source. Hence, updateValues is a better name for this family of functions.
* BarMeterMode_draw minor code improvementExplorer092016-03-221-4/+1
| | | | | | | | | | | | | Removed a loop that sets the bar[] buffer with spaces and merged that task to the snprintf() call just below. No need for the barOffset variable. Display behavior is unchanged. Size comparision (when compiled on Ubuntu 14.04 64-bit): $ size htop.old htop.new text data bss dec hex filename 137312 15112 3776 156200 26228 htop.old 137216 15112 3776 156104 261c8 htop.new
* Explicit "maxItems" property of metersExplorer092016-03-111-6/+3
| | | | | | | | | Two changes in this commit: - All meters now explicitly specify "maxItems" property, even for just 1 item. (Exception is "container" CPU meter classes, which use CUSTOM_METERMODE.) - "maxItems" being 0 is now allowed. This will let bar meters and graph meters render an empty meter.
* Avoid crash on huge screens.Hisham2016-02-021-1/+6
| | | | Fix by @Explorer09 (see discussion on #355).
* Check for failure in allocations.Hisham2016-02-021-5/+5
|
* Change variable 'dot' to avoid division by reciprocal.Explorer092016-01-211-3/+3
| | | | | | | | | | | | | | (Cherry-picked from d56bcd8e0d8d6a177fc2e40db32fc73ea4588684, the experimental graph coloring branch) The variable 'dot' in GraphMeterMode_draw now means "maximum number of dots per value (column) in graph". The old meaning was "amount of value that is to be represented by a dot" and was always a fraction. Due to a limitation in floating point computing, if GRAPH_HEIGHT were not a power of 2, then rounding errors will occur on numbers like (1.0/3). (Currently GRAPH_HEIGHT is 4 and so no precision loss.) 'dot' was used as a divisor, and it's "division by a reciprocal". We change that to simple multiplication.
* New macro GRAPH_HEIGHT for Graph Meter heightExplorer092016-01-211-7/+9
| | | | | | | | (Cherry-picked from e93028d7fa0c5f00b5dc3336fd28abaf905cd572, the experimental graph coloring branch) Currently GRAPH_HEIGHT=4 . This prevents hard-coding the height of the graph meters, and allows user to change it at compile-time.
* Introduce CLAMP macro. Unify all MIN(MAX(a,b),c) uses.Explorer092016-01-151-9/+10
| | | | | | | | | | | | | | | | | | | | | | | With the CLAMP macro replacing the combination of MIN and MAX, we will have at least two advantages: 1. It's more obvious semantically. 2. There are no more mixes of confusing uses like MIN(MAX(a,b),c) and MAX(MIN(a,b),c) and MIN(a,MAX(b,c)) appearing everywhere. We unify the 'clamping' with a single macro. Note that the behavior of this CLAMP macro is different from the combination `MAX(low,MIN(x,high))`. * This CLAMP macro expands to two comparisons instead of three from MAX and MIN combination. In theory, this makes the code slightly smaller, in case that (low) or (high) or both are computed at runtime, so that compilers cannot optimize them. (The third comparison will matter if (low)>(high); see below.) * CLAMP has a side effect, that if (low)>(high) it will produce weird results. Unlike MIN & MAX which will force either (low) or (high) to win. No assertion of ((low)<=(high)) is done in this macro, for now. This CLAMP macro is implemented like described in glib <http://developer.gnome.org/glib/stable/glib-Standard-Macros.html> and does not handle weird uses like CLAMP(a++, low++, high--) .
* Present IO-Wait as a dot in monochrome. Fixes #345.Hisham Muhammad2016-01-111-1/+1
| | | | Thank you @Explorer09 for the report!

© 2014-2024 Faster IT GmbH | imprint | privacy policy