Module: Redcar::Top

Defined in:
plugins/redcar/redcar.rb

Defined Under Namespace

Classes: AboutCommand, ApplicationEventHandler, BackspaceCommand, BackwardCharCommand, BackwardNavigationCommand, ChangeIndentCommand, ChangelogCommand, CopyCommand, CutCommand, DecreaseFontSize, DecreaseIndentCommand, DeleteCharCommand, DuplicateCommand, ForwardCharCommand, ForwardNavigationCommand, GenerateGrammarsMenu, GenerateTabsMenu, GenerateWindowsMenu, GotoLineCommand, IncreaseFontSize, IncreaseIndentCommand, MoveBottomCommand, MoveDownCommand, MoveEndCommand, MoveHomeCommand, MoveNextLineCommand, MoveTopCommand, MoveUpCommand, OpenLineCommand, OpenNewEditTabCommand, PasteCommand, PrintScopeCommand, PrintScopeTreeCommand, RedoCommand, SelectAllCommand, SelectFontSize, SelectLineCommand, SelectNewFont, SelectTheme, SelectWordCommand, ShowTheme, ShowTitle, SortLinesCommand, ToggleBlockSelectionCommand, ToggleInvisibles, ToggleLineNumbers, TransposeCharactersCommand, UndoCommand

Class Method Summary (collapse)

Class Method Details

+ (Object) application_event_handler



1021
1022
1023
# File 'plugins/redcar/redcar.rb', line 1021

def self.application_event_handler
  ApplicationEventHandler.new
end

+ (Object) keymaps



619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
# File 'plugins/redcar/redcar.rb', line 619

def self.keymaps
  osx = Redcar::Keymap.build("main", :osx) do
    link "Cmd+N",       OpenNewEditTabCommand
    link "Cmd+Shift+N", Application::OpenNewNotebookCommand
    link "Cmd+Alt+N",   Application::OpenNewWindowCommand
    link "Cmd+O",       Project::OpenFileCommand
    link "Cmd+U",       Project::FileReloadCommand
    link "Cmd+Shift+O", Project::DirectoryOpenCommand
    link "Cmd+Alt+Ctrl+P",   Project::FindRecentCommand
    link "Cmd+S",       Project::SaveFileCommand
    link "Cmd+Shift+S", Project::SaveFileAsCommand
    link "Cmd+Alt+S",   Project::SaveAllFilesCommand
    link "Cmd+W",       Application::CloseTabCommand
    link "Cmd+Shift+W", Application::CloseWindowCommand
    link "Alt+Shift+W", Application::CloseTreeCommand
    link "Cmd+Q",       Application::QuitCommand

    #link "Cmd+Return",   MoveNextLineCommand

    link "Cmd+Z",        UndoCommand
    link "Cmd+Shift+Z",  RedoCommand
    link "Cmd+X",        CutCommand
    link "Cmd+C",        CopyCommand
    link "Cmd+V",        PasteCommand
    link "Cmd+D",        DuplicateCommand
    link "Ctrl+T",       TransposeCharactersCommand

    link "Home",    MoveTopCommand
    link "Ctrl+A",  MoveHomeCommand
    link "Ctrl+E",  MoveEndCommand
    link "End",     MoveBottomCommand
    link "Ctrl+F",  ForwardCharCommand
    link "Ctrl+B",  BackwardCharCommand
    link "Ctrl+P",  MoveUpCommand
    link "Ctrl+N",  MoveDownCommand
    link "Ctrl+B",  BackwardCharCommand
    link "Ctrl+O",  OpenLineCommand
    link "Ctrl+D",  DeleteCharCommand
    link "Ctrl+H",  BackspaceCommand

    link "Ctrl+Alt+Left", BackwardNavigationCommand
    link "Ctrl+Alt+Right", ForwardNavigationCommand

    link "Cmd+[",            DecreaseIndentCommand
    link "Cmd+]",            IncreaseIndentCommand
    link "Cmd+Shift+I",      AutoIndenter::IndentCommand
    link "Cmd+L",            GotoLineCommand
    link "Cmd+A",            SelectAllCommand
    link "Ctrl+W",           SelectWordCommand
    link "Ctrl+L",           SelectLineCommand
    link "Cmd+B",            ToggleBlockSelectionCommand
    link "Escape",           AutoCompleter::AutoCompleteCommand
    link "Ctrl+Escape",      AutoCompleter::MenuAutoCompleterCommand
    link "Ctrl+Space",       AutoCompleter::AutoCompleteCommand
    link "Ctrl+Shift+Space", AutoCompleter::MenuAutoCompleterCommand

    link "Ctrl+U",       EditView::UpcaseTextCommand
    link "Ctrl+Shift+U", EditView::DowncaseTextCommand
    link "Ctrl+Alt+U",   EditView::TitlizeTextCommand
    link "Ctrl+G",       EditView::OppositeCaseTextCommand
    link "Ctrl+_",       EditView::CamelSnakePascalRotateTextCommand
    link "Ctrl+=",       EditView::AlignAssignmentCommand
    link "Cmd+Alt+Ctrl+L", EditView::ChangeLanguageCommand
    link "Ctrl+Shift+^", SortLinesCommand

    link "Cmd+T",           Project::FindFileCommand
    link "Cmd+Shift+Alt+O", Application::MoveTabToOtherNotebookCommand
    link "Cmd+Alt+O",       Application::SwitchNotebookCommand
    link "Alt+Shift+[",     Application::SwitchTreeUpCommand
    link "Alt+Shift+]",     Application::SwitchTreeDownCommand
    link "Cmd+Shift+[",     Application::SwitchTabDownCommand
    link "Cmd+Shift+]",     Application::SwitchTabUpCommand
    link "Ctrl+Shift+[",    Application::MoveTabDownCommand
    link "Ctrl+Shift+]",    Application::MoveTabUpCommand
    link "Cmd+Shift++",     Application::ToggleFullscreen
    link "Cmd+Shift+T",     Application::OpenTreeFinderCommand
    link "Alt+Shift+J",     Application::IncreaseTreebookWidthCommand
    link "Alt+Shift+H",     Application::DecreaseTreebookWidthCommand
    link "Cmd+Shift+>",     Application::EnlargeNotebookCommand
    link "Cmd+Shift+L",     Application::ResetNotebookWidthsCommand
    link "Cmd+Shift+:",     Application::RotateNotebooksCommand
    link "Alt+Shift+N",     Application::CloseNotebookCommand
    link "Cmd+Alt+I",       ToggleInvisibles
    link "Cmd++",           IncreaseFontSize
    link "Cmd+-",           DecreaseFontSize

    link "Ctrl+Shift+P", PrintScopeCommand
    link "Cmd+Shift+H",  Application::ToggleTreesCommand

    # link "Cmd+Shift+R",     PluginManagerUi::ReloadLastReloadedCommand

    #Textmate.attach_keybindings(self, :osx)

    # map SelectTab<number>Command
    (1..9).each do |tab_num|
      link "Cmd+#{tab_num}", Application.const_get("SelectTab#{tab_num}Command")
    end

  end

  linwin = Redcar::Keymap.build("main", [:linux, :windows]) do
    link "Ctrl+N",       OpenNewEditTabCommand
    link "Ctrl+Shift+N", Application::OpenNewNotebookCommand
    link "Ctrl+Alt+N",   Application::OpenNewWindowCommand
    link "Ctrl+O",       Project::OpenFileCommand
    link "Ctrl+Shift+O", Project::DirectoryOpenCommand
    link "Ctrl+Alt+Shift+P",   Project::FindRecentCommand
    link "Ctrl+S",       Project::SaveFileCommand
    link "Ctrl+Shift+S", Project::SaveFileAsCommand
    link "Ctrl+Alt+S",   Project::SaveAllFilesCommand
    link "Ctrl+W",       Application::CloseTabCommand
    link "Ctrl+Shift+W", Application::CloseWindowCommand
    link "Alt+Shift+W",  Application::CloseTreeCommand
    link "Ctrl+Q",       Application::QuitCommand

    link "Ctrl+Enter",   MoveNextLineCommand

    link "Ctrl+Z",       UndoCommand
    link "Ctrl+Y",       RedoCommand
    link "Ctrl+X",       CutCommand
    link "Ctrl+C",       CopyCommand
    link "Ctrl+V",       PasteCommand
    link "Ctrl+D",       DuplicateCommand

    link "Ctrl+Home",  MoveTopCommand
    link "Home",       MoveHomeCommand
    link "Ctrl+Alt+A", MoveHomeCommand
    link "End",        MoveEndCommand
    link "Ctrl+Alt+E", MoveEndCommand
    link "Ctrl+End",   MoveBottomCommand

    link "Alt+[", BackwardNavigationCommand
    link "Alt+]", ForwardNavigationCommand

    link "Ctrl+[",           DecreaseIndentCommand
    link "Ctrl+]",           IncreaseIndentCommand
    link "Ctrl+Shift+[",     AutoIndenter::IndentCommand
    link "Ctrl+L",           GotoLineCommand
    link "Ctrl+A",           SelectAllCommand
    link "Ctrl+Alt+W",       SelectWordCommand
    link "Ctrl+Alt+L",       SelectLineCommand
    link "Ctrl+B",           ToggleBlockSelectionCommand
    link "Escape",           AutoCompleter::AutoCompleteCommand
    link "Ctrl+Escape",      AutoCompleter::MenuAutoCompleterCommand
    link "Ctrl+Space",       AutoCompleter::AutoCompleteCommand

    link "Ctrl+Shift+Space", AutoCompleter::MenuAutoCompleterCommand

    link "Ctrl+U",           EditView::UpcaseTextCommand
    link "Ctrl+Shift+U",     EditView::DowncaseTextCommand
    link "Ctrl+Alt+U",       EditView::TitlizeTextCommand
    link "Ctrl+Alt+Shift+U", EditView::OppositeCaseTextCommand
    link "Ctrl+_",           EditView::CamelSnakePascalRotateTextCommand
    link "Ctrl+=",           EditView::AlignAssignmentCommand
    link "Ctrl+Alt+Shift+L", EditView::ChangeLanguageCommand
    link "Ctrl+Shift+^",     SortLinesCommand

    link "Ctrl+T",           Project::FindFileCommand
    link "Ctrl+Shift+Alt+O", Application::MoveTabToOtherNotebookCommand

    link "Ctrl+Shift+P", PrintScopeCommand

    link "Ctrl+Alt+O",           Application::SwitchNotebookCommand
    link "Ctrl+Shift+H",         Application::ToggleTreesCommand
    link "Alt+Page Up",          Application::SwitchTreeUpCommand
    link "Alt+Page Down",        Application::SwitchTreeDownCommand
    link "Ctrl+Page Up",         Application::SwitchTabDownCommand
    link "Ctrl+Page Down",       Application::SwitchTabUpCommand
    link "Ctrl+Shift+Page Up",   Application::MoveTabDownCommand
    link "Ctrl+Shift+Page Down", Application::MoveTabUpCommand
    link "Ctrl+Shift+T",         Application::OpenTreeFinderCommand
    link "Alt+Shift+J",          Application::IncreaseTreebookWidthCommand
    link "Alt+Shift+H",          Application::DecreaseTreebookWidthCommand
    link "Ctrl+Shift+>",         Application::EnlargeNotebookCommand
    link "Ctrl+Shift+L",         Application::ResetNotebookWidthsCommand
    link "Ctrl+Shift+:",         Application::RotateNotebooksCommand
    link "Alt+Shift+N",          Application::CloseNotebookCommand
    link "F11",                  Application::ToggleFullscreen
    link "Ctrl+Alt+I",           ToggleInvisibles
    link "Ctrl++",               IncreaseFontSize
    link "Ctrl+-",               DecreaseFontSize

    #Textmate.attach_keybindings(self, :linux)

    # map SelectTab<number>Command
    (1..9).each do |tab_num|
      link "Alt+#{tab_num}", Application.const_get("SelectTab#{tab_num}Command")
    end

  end

  [linwin, osx]
end


828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
# File 'plugins/redcar/redcar.rb', line 828

def self.menus(window)
  Menu::Builder.build do
    sub_menu "File", :priority => :first do
      group(:priority => :first) do
        item "New", OpenNewEditTabCommand
        item "New Window", Application::OpenNewWindowCommand
      end

      group(:priority => 10) do
        separator
        item "Close Tab", Application::CloseTabCommand
        item "Close Tree", Application::CloseTreeCommand
        item "Close Window", Application::CloseWindowCommand
        item "Close Others", Application::CloseOthers
        item "Close All", Application::CloseAll
      end

      group(:priority => :last) do
        separator
        item "Quit", Application::QuitCommand
      end
    end

    sub_menu "Edit", :priority => 5 do
      group(:priority => :first) do
        item "Undo", UndoCommand
        item "Redo", RedoCommand
        separator
      end

      group(:priority => 15) do
        item "Cut", CutCommand
        item "Copy", CopyCommand
        item "Paste", PasteCommand
        sub_menu "Line Tools", :priority => 20 do
          item "Duplicate Region", DuplicateCommand
          item "Sort Lines in Region", SortLinesCommand
        end
        separator
      end

      group(:priority => 30) do
        sub_menu "Selection" do
          item "All", SelectAllCommand
          item "Line", SelectLineCommand
          item "Current Word", SelectWordCommand
          item "Toggle Block Selection", ToggleBlockSelectionCommand
        end

        sub_menu "Document Navigation" do
          item "Goto Line", GotoLineCommand
          item "Top",     MoveTopCommand
          item "Home",    MoveHomeCommand
          item "End",     MoveEndCommand
          item "Bottom",  MoveBottomCommand

          separator

          item "Forward Character",  ForwardCharCommand
          item "Backward Character", BackwardCharCommand
          item "Previous Line",      MoveUpCommand
          item "Next Line",          MoveDownCommand
          item "Open Line",          OpenLineCommand

          separator

          item "Delete Character",   DeleteCharCommand
          item "Backspace",          BackspaceCommand
          item "Transpose",          TransposeCharactersCommand

          separator

          item "Backward Navigation", BackwardNavigationCommand
          item "Forward Navigation", ForwardNavigationCommand
        end

        sub_menu "Formatting" do
          item "Increase Indent", IncreaseIndentCommand
          item "Decrease Indent", DecreaseIndentCommand
        end
      end

    end
    sub_menu "Debug", :priority => 20 do
      group(:priority => 10) do
        item "Print Scope Tree", PrintScopeTreeCommand
        item "Print Scope at Cursor", PrintScopeCommand
      end
    end
    sub_menu "View", :priority => 30 do
      sub_menu "Appearance", :priority => 5 do
        item "Select Theme", SelectTheme
        separator
        item "Select Font" , SelectNewFont
        item "Select Font Size"  , SelectFontSize
        item "Increase Font Size", IncreaseFontSize
        item "Decrease Font Size", DecreaseFontSize
      end
      group(:priority => 10) do
        separator
        item "Toggle Fullscreen", :command => Application::ToggleFullscreen, :type => :check, :checked => window ? window.fullscreen : false
      end
      group(:priority => 15) do
        separator
        sub_menu "Trees" do
          item "Open Tree Finder", Application::OpenTreeFinderCommand
          item "Toggle Tree Visibility", Application::ToggleTreesCommand
          item "Increase Tree Width", Application::IncreaseTreebookWidthCommand
          item "Decrease Tree Width", Application::DecreaseTreebookWidthCommand
          separator
          item "Previous Tree", Application::SwitchTreeUpCommand
          item "Next Tree", Application::SwitchTreeDownCommand
        end
        lazy_sub_menu "Windows" do
          GenerateWindowsMenu.on(self)
        end
        sub_menu "Notebooks" do
          item "New Notebook", Application::OpenNewNotebookCommand
          item "Close Notebook", Application::CloseNotebookCommand
          item "Rotate Notebooks", Application::RotateNotebooksCommand
          item "Move Tab To Other Notebook", Application::MoveTabToOtherNotebookCommand
          item "Switch Notebooks", Application::SwitchNotebookCommand
          separator
          item "Enlarge First Notebook", Application::EnlargeNotebookCommand
          item "Reset Notebook Widths",  Application::ResetNotebookWidthsCommand
        end
        sub_menu "Tabs" do
          item "Previous Tab",   Application::SwitchTabDownCommand
          item "Next Tab",       Application::SwitchTabUpCommand
          item "Move Tab Left",  Application::MoveTabDownCommand
          item "Move Tab Right", Application::MoveTabUpCommand
          separator
          # GenerateTabsMenu.new(self).run # TODO: find a way to maintain keybindings with lazy menus
          item "Focussed Notebook", ShowTitle
          (1..9).each do |num|
            item "Tab #{num}", Application.const_get("SelectTab#{num}Command")
          end
        end
      end
      group(:priority => :last) do
        separator
        item "Show Toolbar", :command => Application::ToggleToolbar, :type => :check, :checked => lambda { Redcar.app.show_toolbar? }
        item "Show Invisibles", :command => ToggleInvisibles, :type => :check, :checked => lambda { EditView.show_invisibles? }
        item "Show Line Numbers", :command => ToggleLineNumbers, :type => :check, :checked => lambda { EditView.show_line_numbers? }
      end
    end
    sub_menu "Bundles", :priority => 45 do
      group(:priority => :first) do
        item "Find Snippet", Snippets::OpenSnippetExplorer
        item "Installed Bundles", Textmate::InstalledBundles
        item "Browse Snippets", Textmate::ShowSnippetTree
      end
      group(:priority => 15) do
        separator
        Textmate.attach_menus(self)
      end
    end
    sub_menu "Help", :priority => :last do
      group(:priority => :last) do
        item "About", AboutCommand
        item "New In This Version", ChangelogCommand
        separator
        item "Check for Updates", :command => Application::ToggleCheckForUpdatesCommand,
                                  :type => :check,
                                  :checked => lambda { Application::Updates.check_for_updates? }
        item "Update Available",  Application::OpenUpdateCommand
      end
    end
  end
end

+ (Object) start(args = [])



1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
# File 'plugins/redcar/redcar.rb', line 1025

def self.start(args=[])
  begin
    Redcar.log.info("startup milestone: loading plugins took #{Time.now - Redcar.process_start_time}")
    Redcar.update_gui do
      Redcar.plugin_manager.objects_implementing(:start_with_app).each do |object|
        object.start_with_app
      end

      SplashScreen.splash_screen.inc(1) if SplashScreen.splash_screen
      s = Time.now
      if Redcar.gui
        Redcar.app.controller = ApplicationSWT.new(Redcar.app)
      end
      Redcar.app.refresh_menu!
      Redcar.app.load_sensitivities
      Redcar.log.info("initializing gui took #{Time.now - s}s")
    end
    Redcar.update_gui do
      SplashScreen.splash_screen.close if SplashScreen.splash_screen
      win = Redcar.app.make_sure_at_least_one_window_there
      Redcar.log.info("startup milestone: window open #{Time.now - Redcar.process_start_time}")
      Redcar::Project::Manager.start(args)
      Redcar.log.info("startup milestone: project open #{Time.now - Redcar.process_start_time}")
      win.show if win and !args.include?("--no-window")
    end
    Redcar.log.info("startup milestone: complete: #{Time.now - Redcar.process_start_time}")
    if args.include?("--compute-textmate-cache-and-quit")
      Redcar::Textmate.all_bundles
      exit
    end
    Thread.new do
      Application.check_for_new_version
    end
  rescue => e
    Redcar.log.error("error in startup: #{e.inspect}")
    e.backtrace.each do |line|
      Redcar.log.error(line)
    end
  end
end

+ (Object) toolbars



813
814
815
816
817
818
819
820
821
822
823
824
825
# File 'plugins/redcar/redcar.rb', line 813

def self.toolbars
  ToolBar::Builder.build do
    item "New File", :command => OpenNewEditTabCommand, :icon => :new, :barname => :core
    item "Open File", :command => Project::OpenFileCommand, :icon => :open, :barname => :core
    item "Open Directory", :command => Project::DirectoryOpenCommand, :icon => :open_dir, :barname => :core
    item "Save File", :command => Project::SaveFileCommand, :icon => :save, :barname => :core
    item "Save File As", :command => Project::SaveFileAsCommand, :icon => :save_as, :barname => :core
    item "Undo", :command => UndoCommand, :icon => :undo, :barname => :core
    item "Redo", :command => RedoCommand, :icon => :redo, :barname => :core
    item "New Notebook", :command => Application::OpenNewNotebookCommand, :icon => File.join(Redcar.icons_directory, "book--plus.png"), :barname => :edit
    item "Close Notebook", :command => Application::CloseNotebookCommand, :icon => File.join(Redcar.icons_directory, "book--minus.png"), :barname => :edit
  end
end