Модератор: Модераторы
Alex2013 писал(а):Working in Virtual Reality
Awkward писал(а):Извините, но вам не кажется, что мы немного отошли от темы?

Awkward писал(а):Извините, но вам не кажется, что мы немного отошли от темы?
Shleps писал(а):есть такое, может мы с Алексом в личку с этим спором пойдем? или в другую ветку? профильную?
и сообщения перенести.
 Виртуальная и дополненная реальность. Ждем Бума?
  Виртуальная и дополненная реальность. Ждем Бума? 
 Alex2013 писал(а):Будет ли версия под Винду и/или Андроид ?
Alex2013 писал(а):Будет ли версия под Винду ... ?

Vadim писал(а):Господи, спаси нас от этих казней египетских!



program ac;
{$MODE OBJFPC}
{$H+}
{
    Commander.
    For GNU/Linux 64 bit version.
    Version: 2.
    Written on FreePascal (https://freepascal.org/).
    Copyright (C) 2025  Artyomov Alexander
    Used: https://chatgpt.com
    http://self-made-free.ru/
    aralni@mail.ru
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as
    published by the Free Software Foundation, either version 3 of the
    License, or (at your option) any later version.
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.
    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.
}
uses
  Crt, SysUtils, BaseUnix, Unix;
type
  TPanel = record
    Path: string;
    Files: array of string;
    Selected: integer;
    Offset: integer;
  end;
const
  PanelHeight = 17;
var
  LeftPanel, RightPanel: TPanel;
  ActivePanel: ^TPanel;
procedure LoadPanel(var Panel: TPanel);
var
  SR: TSearchRec;
begin
  SetLength(Panel.Files, 0);
  if FindFirst(Panel.Path + '/*', faAnyFile, SR) = 0 then
  begin
    repeat
      SetLength(Panel.Files, Length(Panel.Files) + 1);
      Panel.Files[High(Panel.Files)] := Panel.Path + '/' + SR.Name;
    until FindNext(SR) <> 0;
    FindClose(SR);
  end;
  if Length(Panel.Files) = 0 then
    Panel.Selected := -1
  else
    Panel.Selected := 0;
  Panel.Offset := 0;
end;
procedure DrawPanel(const Panel: TPanel; X: integer; Active: boolean);
var
  I, DisplayIndex: integer;
begin
  for I := 0 to PanelHeight - 1 do
  begin
    DisplayIndex := Panel.Offset + I;
    GotoXY(X, I + 2);
    if (DisplayIndex < Length(Panel.Files)) then
    begin
      if DisplayIndex = Panel.Selected then
        TextBackground(Blue)
      else if Active then
        TextBackground(Black)
      else
        TextBackground(Red);
      Write(Copy(ExtractFileName(Panel.Files[DisplayIndex]), 1, 38):38);
    end
    else
      Write(' ':38);
    TextBackground(Black);
  end;
end;
procedure RefreshScreen;
begin
  ClrScr;
  GotoXY(2, 1);
  Write('[q] Exit  [v] View/Run/Cd  [c] Cp  [m] Mv  [d] Rm  [t] Tab  [j] Down  [k] Up');
  DrawPanel(LeftPanel, 2, ActivePanel = @LeftPanel);
  DrawPanel(RightPanel, 42, ActivePanel = @RightPanel);
end;
procedure ViewFile;
var
  FilePath: string;
begin
  if (ActivePanel^.Selected >= 0) and (ActivePanel^.Selected < Length(ActivePanel^.Files)) then
  begin
    FilePath := ActivePanel^.Files[ActivePanel^.Selected];
    if DirectoryExists(FilePath) then
    begin
      ActivePanel^.Path := FilePath;
      LoadPanel(ActivePanel^);
    end
    else if fpAccess(FilePath, X_OK) = 0 then
      fpSystem('"' + FilePath + '"')
    else
      fpSystem('xdg-open "' + FilePath + '"');
  end;
end;
procedure CopyFile;
var
  Dest: string;
begin
  if (ActivePanel^.Selected >= 0) then
  begin
    Dest := RightPanel.Path + '/' + ExtractFileName(ActivePanel^.Files[ActivePanel^.Selected]);
    if fpSystem('cp "' + ActivePanel^.Files[ActivePanel^.Selected] + '" "' + Dest + '"') <> 0 then
      WriteLn('Ошибка копирования.');
    LoadPanel(LeftPanel);
    LoadPanel(RightPanel);
  end;
end;
procedure MoveFile;
var
  Dest: string;
begin
  if (ActivePanel^.Selected >= 0) then
  begin
    Dest := RightPanel.Path + '/' + ExtractFileName(ActivePanel^.Files[ActivePanel^.Selected]);
    if fpSystem('mv "' + ActivePanel^.Files[ActivePanel^.Selected] + '" "' + Dest + '"') <> 0 then
      WriteLn('Ошибка перемещения.');
    LoadPanel(LeftPanel);
    LoadPanel(RightPanel);
  end;
end;
procedure DeleteFile;
begin
  if (ActivePanel^.Selected >= 0) then
  begin
    if fpSystem('rm "' + ActivePanel^.Files[ActivePanel^.Selected] + '"') <> 0 then
      WriteLn('Ошибка удаления.');
    LoadPanel(LeftPanel);
    LoadPanel(RightPanel);
  end;
end;
procedure HandleInput;
var
  Key: char;
begin
  Key := ReadKey;
  case Key of
    'q': Halt;
    'j': if ActivePanel^.Selected < High(ActivePanel^.Files) then
         begin
           Inc(ActivePanel^.Selected);
           if ActivePanel^.Selected - ActivePanel^.Offset >= PanelHeight then
             Inc(ActivePanel^.Offset);
         end;
    'k': if ActivePanel^.Selected > 0 then
         begin
           Dec(ActivePanel^.Selected);
           if ActivePanel^.Selected < ActivePanel^.Offset then
             Dec(ActivePanel^.Offset);
         end;
    'v': ViewFile;
    'c': CopyFile;
    'm': MoveFile;
    'd': DeleteFile;
    't': if ActivePanel = @LeftPanel then ActivePanel := @RightPanel else ActivePanel := @LeftPanel;
  end;
end;
begin
  LeftPanel.Path := GetCurrentDir;
  RightPanel.Path := GetCurrentDir;
  ActivePanel := @LeftPanel;
  LoadPanel(LeftPanel);
  LoadPanel(RightPanel);
  repeat
    RefreshScreen;
    HandleInput;
  until False;
end.


alexs писал(а):Насколько я помню - FV тоже не умеет UTF8 правильно отображать.
Alexander писал(а):я озадачил ИИ

Alex2013 писал(а):ИМХО сейчас наверное проще взять FreeVision и сделать простой ДН-подобный файловий менеджер с нуля, чем мучить "легаси исходники".
Снег Север писал(а):Как говорят мудрецы, нельзя в одну реку войти дважды. ДН был очень хорош во времена ДОС, а сегодня он - полнейший анахронизм.
Вернуться в Разработки на нашем сайте
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 1