Method: CDK::VIEWER#activate
- Defined in:
- lib/cdk/components/viewer.rb
#activate(actions) ⇒ Object
This function actually controls the viewer…
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 |
# File 'lib/cdk/components/viewer.rb', line 325 def activate(actions) refresh = false # Create the information about the file stats. file_info = [ '</5> </U>File Statistics<!U> <!5>', '</5> <!5>', '</5/R>Character Count:<!R> %-4d <!5>' % @characters, '</5/R>Line Count :<!R> %-4d <!5>' % @list_size, '</5> <!5>', '<C></5>Press Any Key To Continue.<!5>' ] temp_info = ['<C></5>Press Any Key To Continue.<!5>'] # Set the current button. @current_button = 0 # Draw the widget list. self.draw(@box) # Do this until KEY_ENTER is hit. while true # Reset the refresh flag. refresh = false input = self.getch([]) if !self.checkBind(:VIEWER, input) case input when CDK::KEY_TAB if @button_count > 1 if @current_button == @button_count - 1 @current_button = 0 else @current_button += 1 end # Redraw the buttons. self.drawButtons end when CDK::PREV if @button_count > 1 if @current_button == 0 @current_button = @button_count - 1 else @current_button -= 1 end # Redraw the buttons. self.drawButtons end when Ncurses::KEY_UP if @current_top > 0 @current_top -= 1 refresh = true else CDK.Beep end when Ncurses::KEY_DOWN if @current_top < @max_top_line @current_top += 1 refresh = true else CDK.Beep end when Ncurses::KEY_RIGHT if @left_char < @max_left_char @left_char += 1 refresh = true else CDK.Beep end when Ncurses::KEY_LEFT if @left_char > 0 @left_char -= 1 refresh = true else CDK.Beep end when Ncurses::KEY_PPAGE if @current_top > 0 if @current_top - (@view_size - 1) > 0 @current_top = @current_top - (@view_size - 1) else @current_top = 0 end refresh = true else CDK.Beep end when Ncurses::KEY_NPAGE if @current_top < @max_top_line if @current_top + @view_size < @max_top_line @current_top = @current_top + (@view_size - 1) else @current_top = @max_top_line end refresh = true else CDK.Beep end when Ncurses::KEY_HOME @left_char = 0 refresh = true when Ncurses::KEY_END @left_char = @max_left_char refresh = true when 'g'.ord, '1'.ord, '<'.ord @current_top = 0 refresh = true when 'G'.ord, '>'.ord @current_top = @max_top_line refresh = true when 'L'.ord x = (@list_size + @current_top) / 2 if x < @max_top_line @current_top = x refresh = true else CDK.Beep end when 'l'.ord x = @current_top / 2 if x >= 0 @current_top = x refresh = true else CDK.Beep end when '?'.ord @search_direction = CDK::VIEWER::UP self.getAndStorePattern(@screen) if !self.searchForWord(@search_pattern, @search_direction) self.PatternNotFound(@search_pattern) end refresh = true when '/'.ord @search_direction = CDK::VIEWER:DOWN self.getAndStorePattern(@screen) if !self.searchForWord(@search_pattern, @search_direction) self.PatternNotFound(@search_pattern) end refresh = true when 'N'.ord, 'n'.ord if @search_pattern == '' temp_info[0] = '</5>There is no pattern in the buffer.<!5>' self.popUpLabel(temp_info) elsif !self.searchForWord(@search_pattern, if input == 'n'.ord then @search_direction else 1 - @search_direction end) self.PatternNotFound(@search_pattern) end refresh = true when ':'.ord @current_top = self.jumpToLine refresh = true when 'i'.ord, 's'.ord, 'S'.ord self.popUpLabel(file_info) refresh = true when CDK::KEY_ESC self.setExitType(input) return -1 when Ncurses::ERR self.setExitType(input) return -1 when Ncurses::KEY_ENTER, CDK::KEY_RETURN self.setExitType(input) return @current_button when CDK::REFRESH @screen.erase @screen.refresh else CDK.Beep end end # Do we need to redraw the screen? if refresh self.drawInfo end end end |