@@ -50,6 +50,7 @@ define(function (require, exports, module) {
5050 KeyEvent = brackets . getModule ( "utils/KeyEvent" ) ,
5151 Commands = brackets . getModule ( "command/Commands" ) ,
5252 FileSystem = brackets . getModule ( "filesystem/FileSystem" ) ,
53+ MainViewManager = brackets . getModule ( "view/MainViewManager" ) ,
5354 FileUtils = brackets . getModule ( "file/FileUtils" ) ,
5455 PreferencesManager = brackets . getModule ( "preferences/PreferencesManager" ) ,
5556 Editor = brackets . getModule ( "editor/Editor" ) ,
@@ -425,6 +426,14 @@ define(function (require, exports, module) {
425426 return PreferencesManager . get ( key ) ;
426427 }
427428
429+ // Helper function to get full path (reusing existing openFile logic)
430+ function _getFullPath ( filePath ) {
431+ if ( filePath . startsWith ( '/' ) ) {
432+ return filePath ;
433+ }
434+ return path . join ( ProjectManager . getProjectRoot ( ) . fullPath , filePath ) ;
435+ }
436+
428437 const EDITING = {
429438 setEditorSpacing : function ( useTabs , spaceOrTabCount , isAutoMode ) {
430439 const activeEditor = EditorManager . getActiveEditor ( ) ;
@@ -442,6 +451,85 @@ define(function (require, exports, module) {
442451 } else {
443452 Editor . Editor . setSpaceUnits ( spaceOrTabCount , fullPath ) ;
444453 }
454+ } ,
455+ /**
456+ * Split the editor pane vertically
457+ */
458+ splitVertical : function ( ) {
459+ CommandManager . execute ( Commands . CMD_SPLITVIEW_VERTICAL ) ;
460+ } ,
461+
462+ /**
463+ * Split the editor pane horizontally
464+ */
465+ splitHorizontal : function ( ) {
466+ CommandManager . execute ( Commands . CMD_SPLITVIEW_HORIZONTAL ) ;
467+ } ,
468+
469+ /**
470+ * Remove split pane and return to single pane view
471+ */
472+ splitNone : function ( ) {
473+ CommandManager . execute ( Commands . CMD_SPLITVIEW_NONE ) ;
474+ } ,
475+ /**
476+ * Gets the editor in the first pane (left/top)
477+ * @return {?Editor } The editor in first pane or null if not available
478+ */
479+ getFirstPaneEditor : function ( ) {
480+ return MainViewManager . getCurrentlyViewedEditor ( "first-pane" ) ;
481+ } ,
482+
483+ /**
484+ * Gets the editor in the second pane (right/bottom)
485+ * @return {?Editor } The editor in second pane or null if not available
486+ */
487+ getSecondPaneEditor : function ( ) {
488+ return MainViewManager . getCurrentlyViewedEditor ( "second-pane" ) ;
489+ } ,
490+
491+ /**
492+ * Checks if the view is currently split
493+ * @return {boolean } True if view is split, false otherwise
494+ */
495+ isSplit : function ( ) {
496+ return MainViewManager . getPaneCount ( ) > 1 ;
497+ } ,
498+ /**
499+ * Opens a file in the first pane (left/top)
500+ * @param {string } filePath - Project relative or absolute file path
501+ * @returns {Promise } A promise that resolves when the file is opened
502+ */
503+ openFileInFirstPane : function ( filePath ) {
504+ return jsPromise ( CommandManager . execute ( Commands . FILE_OPEN , {
505+ fullPath : _getFullPath ( filePath ) ,
506+ paneId : "first-pane"
507+ } ) ) ;
508+ } ,
509+
510+ /**
511+ * Opens a file in the second pane (right/bottom)
512+ * @param {string } filePath - Project relative or absolute file path
513+ * @returns {Promise } A promise that resolves when the file is opened
514+ */
515+ openFileInSecondPane : function ( filePath ) {
516+ return jsPromise ( CommandManager . execute ( Commands . FILE_OPEN , {
517+ fullPath : _getFullPath ( filePath ) ,
518+ paneId : "second-pane"
519+ } ) ) ;
520+ } ,
521+ /**
522+ * Focus the first pane (left/top)
523+ */
524+ focusFirstPane : function ( ) {
525+ MainViewManager . setActivePaneId ( "first-pane" ) ;
526+ } ,
527+
528+ /**
529+ * Focus the second pane (right/bottom)
530+ */
531+ focusSecondPane : function ( ) {
532+ MainViewManager . setActivePaneId ( "second-pane" ) ;
445533 }
446534 } ;
447535
0 commit comments