Был у меня helloworld под офтопик который перехватывал консольный ввод и заменял вводимые символы символом *.
Вот код
unit consolepassword;
{$MODE Delphi}
interface
procedure ConsoleGetPassword (var Password : string);
implementation
uses
  SysUtils,Windows;
var
  consoleHandle: THandle;
  ConsoleAttr: _CONSOLE_SCREEN_BUFFER_INFO;
function EnableEcho(const ShowText: Boolean): Cardinal;
begin
  GetConsoleMode(consoleHandle, Result);
  if ShowText then
    SetConsoleMode(consoleHandle, Result or ENABLE_ECHO_INPUT)
  else
    SetConsoleMode(consoleHandle, Result and not ENABLE_ECHO_INPUT);
end;
function KeyPressed: Char;
var
  oldMode: Cardinal;
  bufSize: Cardinal;
begin
  GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), OldMode);
  SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), oldMode and not
(ENABLE_LINE_INPUT or ENABLE_ECHO_INPUT));
  ReadConsole(GetStdHandle(STD_INPUT_HANDLE), @Result, 1, bufSize,
nil);
  SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), oldMode);
end;
procedure GotoXY(X, Y: Word);
var
  pos: COORD;
begin
  pos.X := X;
  pos.Y := Y;
  SetConsoleCursorPosition(STD_INPUT_HANDLE, pos);
end;
function GetPassword(const MaskChar: Char = '*'): string;
var
  c: Char;
begin
  Writeln;
  Write('Enter Password: ');
  EnableEcho(False);
  while True do
  begin
    c := KeyPressed();
    case c of
      #13: Break;
      #8:
      begin
        if Length(Result) > 0 then
        begin
          Delete(Result, Length(Result), 1);
          GotoXY(ConsoleAttr.dwCursorPosition.X - 1,
            ConsoleAttr.dwCursorPosition.Y);
          Write(' ');
          GotoXY(ConsoleAttr.dwCursorPosition.X - 1,
            ConsoleAttr.dwCursorPosition.Y);
        end;
      end;
    else
      Result := Result + c;
      Write(MaskChar);
    end;
  end;
  EnableEcho(True);
end;
// main
procedure ConsoleGetPassword (var Password : string);
begin
  consoleHandle := GetStdHandle(STD_OUTPUT_HANDLE);
  GetConsoleScreenBufferInfo(consoleHandle, ConsoleAttr);
  Password := GetPassword();
end;
end.
Я теперь хочу другой helloworld, который использует этот модуль собрать Lazarus'ом под онтопик. Как правильно его перенести на Linux?









