~ubuntu-branches/ubuntu/maverick/htop/maverick

« back to all changes in this revision

Viewing changes to Panel.c

  • Committer: Bazaar Package Importer
  • Author(s): Bhavani Shankar
  • Date: 2009-07-09 11:32:08 UTC
  • mfrom: (2.1.8 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090709113208-ts9xcebsg5kyyx1b
Tags: 0.8.3-1ubuntu1
* Merge from debian unstable, remaining changes: (LP: #385862)
  - debian/patches/910-ubuntu-64bit-ram-alignment.patch
    + Refresh patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
94
94
   this->selected = 0;
95
95
   this->oldSelected = 0;
96
96
   this->needsRedraw = true;
97
 
   this->header.len = 0;
 
97
   RichString_prune(&(this->header));
98
98
   if (String_eq(CRT_termType, "linux"))
99
 
      this->scrollHAmount = 40;
 
99
      this->scrollHAmount = 20;
100
100
   else
101
101
      this->scrollHAmount = 5;
102
102
}
213
213
   return this->selected;
214
214
}
215
215
 
216
 
int Panel_getSize(Panel* this) {
 
216
int Panel_size(Panel* this) {
217
217
   assert (this != NULL);
218
218
 
219
219
   return Vector_size(this->items);
326
326
   move(0, 0);
327
327
}
328
328
 
329
 
void Panel_onKey(Panel* this, int key) {
 
329
bool Panel_onKey(Panel* this, int key) {
330
330
   assert (this != NULL);
331
331
   switch (key) {
332
332
   case KEY_DOWN:
333
333
      if (this->selected + 1 < Vector_size(this->items))
334
334
         this->selected++;
335
 
      break;
 
335
      return true;
336
336
   case KEY_UP:
337
337
      if (this->selected > 0)
338
338
         this->selected--;
339
 
      break;
 
339
      return true;
 
340
   #ifdef KEY_C_DOWN
 
341
   case KEY_C_DOWN:
 
342
      if (this->selected + 1 < Vector_size(this->items)) {
 
343
         this->selected++;
 
344
         if (this->scrollV < Vector_size(this->items) - this->h) {
 
345
            this->scrollV++;
 
346
            this->needsRedraw = true;
 
347
         }
 
348
      }
 
349
      return true;
 
350
   #endif
 
351
   #ifdef KEY_C_UP
 
352
   case KEY_C_UP:
 
353
      if (this->selected > 0) {
 
354
         this->selected--;
 
355
         if (this->scrollV > 0) {
 
356
            this->scrollV--;
 
357
            this->needsRedraw = true;
 
358
         }
 
359
      }
 
360
      return true;
 
361
   #endif
340
362
   case KEY_LEFT:
341
363
      if (this->scrollH > 0) {
342
 
         this->scrollH -= this->scrollHAmount;
 
364
         this->scrollH -= 5;
343
365
         this->needsRedraw = true;
344
366
      }
345
 
      break;
 
367
      return true;
346
368
   case KEY_RIGHT:
347
 
      this->scrollH += this->scrollHAmount;
 
369
      this->scrollH += 5;
348
370
      this->needsRedraw = true;
349
 
      break;
 
371
      return true;
350
372
   case KEY_PPAGE:
351
 
      this->selected -= this->h;
 
373
      this->selected -= (this->h - 1);
 
374
      this->scrollV -= (this->h - 1);
352
375
      if (this->selected < 0)
353
376
         this->selected = 0;
354
 
      break;
 
377
      if (this->scrollV < 0)
 
378
         this->scrollV = 0;
 
379
      this->needsRedraw = true;
 
380
      return true;
355
381
   case KEY_NPAGE:
356
 
      this->selected += this->h;
 
382
      this->selected += (this->h - 1);
357
383
      int size = Vector_size(this->items);
358
384
      if (this->selected >= size)
359
385
         this->selected = size - 1;
360
 
      break;
 
386
      this->scrollV += (this->h - 1);
 
387
      if (this->scrollV >= MAX(0, size - this->h))
 
388
         this->scrollV = MAX(0, size - this->h - 1);
 
389
      this->needsRedraw = true;
 
390
      return true;
361
391
   case KEY_HOME:
362
392
      this->selected = 0;
363
 
      break;
 
393
      return true;
364
394
   case KEY_END:
365
395
      this->selected = Vector_size(this->items) - 1;
366
 
      break;
 
396
      return true;
367
397
   }
 
398
   return false;
368
399
}